Skip to content

Commit d5c9976

Browse files
Merge branch 'master' into ci-remove-install-npm
2 parents e868d81 + 276abcd commit d5c9976

File tree

19 files changed

+3085
-2812
lines changed

19 files changed

+3085
-2812
lines changed

README.md

Lines changed: 137 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,40 @@ This plugin uses [`stylelint`](https://stylelint.io/) that helps you avoid error
2121

2222
To begin, you'll need to install `stylelint-webpack-plugin`:
2323

24-
```bash
24+
```console
2525
npm install stylelint-webpack-plugin --save-dev
2626
```
2727

28+
or
29+
30+
```console
31+
yarn add -D install stylelint-webpack-plugin
32+
```
33+
34+
or
35+
36+
```console
37+
pnpm add -D stylelint-webpack-plugin
38+
```
39+
2840
**Note**: You also need to install `stylelint >= 13` from npm, if you haven't already:
2941

30-
```bash
42+
```console
3143
npm install stylelint --save-dev
3244
```
3345

46+
or
47+
48+
```console
49+
yarn add -D stylelint
50+
```
51+
52+
or
53+
54+
```console
55+
pnpm add -D stylelint
56+
```
57+
3458
**Note**: If you are using Stylelint 13 rather than 14+, you might also need to install `@types/stylelint` as a dev dependency if getting stylelint related type errors.
3559

3660
Then add the plugin to your webpack config. For example:
@@ -51,7 +75,12 @@ See [stylelint's options](https://stylelint.io/user-guide/usage/node-api#options
5175

5276
### `configFile`
5377

54-
- Type: `String`
78+
- Type:
79+
80+
```ts
81+
type context = string;
82+
```
83+
5584
- Default: `undefined`
5685

5786
Specify the config file location to be used by `stylelint`.
@@ -60,63 +89,110 @@ Specify the config file location to be used by `stylelint`.
6089

6190
### `context`
6291

63-
- Type: `String`
92+
- Type:
93+
94+
```ts
95+
type context = string;
96+
```
97+
6498
- Default: `compiler.context`
6599

66100
A string indicating the root of your files.
67101

68102
### `exclude`
69103

70-
- Type: `String|Array[String]`
104+
- Type:
105+
106+
```ts
107+
type exclude = string | Array<string>;
108+
```
109+
71110
- Default: `['node_modules', compiler.options.output.path]`
72111

73112
Specify the files and/or directories to exclude. Must be relative to `options.context`.
74113

75114
### `extensions`
76115

77-
- Type: `String|Array[String]`
116+
- Type:
117+
118+
```ts
119+
type extensions = string | Array<string>;
120+
```
121+
78122
- Default: `['css', 'scss', 'sass']`
79123

80124
Specify extensions that should be checked.
81125

82126
### `files`
83127

84-
- Type: `String|Array[String]`
128+
- Type:
129+
130+
```ts
131+
type files = string | Array<string>;
132+
```
133+
85134
- Default: `null`
86135

87-
Specify directories, files, or globs. Must be relative to `options.context`. Directories are traveresed recursively looking for files matching `options.extensions`. File and glob patterns ignore `options.extensions`.
136+
Specify directories, files, or globs. Must be relative to `options.context`. Directories are traversed recursively looking for files matching `options.extensions`. File and glob patterns ignore `options.extensions`.
88137

89138
### `fix`
90139

91-
- Type: `Boolean`
140+
- Type:
141+
142+
```ts
143+
type fix = boolean;
144+
```
145+
92146
- Default: `false`
93147

94148
If `true`, `stylelint` will fix as many errors as possible. The fixes are made to the actual source files. All unfixed errors will be reported. See [Autofixing errors](https://stylelint.io/user-guide/usage/options#fix) docs.
95149

96150
### `formatter`
97151

98-
- Type: `String|Function`
152+
- Type:
153+
154+
```ts
155+
type formatter = string | (
156+
results: Array<import('stylelint').LintResult>
157+
) => string
158+
```
159+
99160
- Default: `'string'`
100161
101162
Specify the formatter that you would like to use to format your results. See [formatter option](https://stylelint.io/user-guide/usage/options#formatter).
102163
103164
### `lintDirtyModulesOnly`
104165
105-
- Type: `Boolean`
166+
- Type:
167+
168+
```ts
169+
type lintDirtyModulesOnly = boolean;
170+
```
171+
106172
- Default: `false`
107173

108174
Lint only changed files, skip lint on start.
109175

110176
### `stylelintPath`
111177

112-
- Type: `String`
178+
- Type:
179+
180+
```ts
181+
type stylelintPath = string;
182+
```
183+
113184
- Default: `stylelint`
114185

115186
Path to `stylelint` instance that will be used for linting.
116187

117188
### `threads`
118189

119-
- Type: `Boolean | Number`
190+
- Type:
191+
192+
```ts
193+
type threads = boolean | number;
194+
```
195+
120196
- Default: `false`
121197

122198
Set to true for an auto-selected pool size based on number of cpus. Set to a number greater than 1 to set an explicit pool size. Set to false, 1, or less to disable and only run in main process.
@@ -128,42 +204,84 @@ You can still force this behavior by using `emitError` **or** `emitWarning` opti
128204

129205
#### `emitError`
130206

131-
- Type: `Boolean`
207+
- Type:
208+
209+
```ts
210+
type emitError = boolean;
211+
```
212+
132213
- Default: `true`
133214

134215
The errors found will always be emitted, to disable set to `false`.
135216

136217
#### `emitWarning`
137218

138-
- Type: `Boolean`
219+
- Type:
220+
221+
```ts
222+
type emitWarning = boolean;
223+
```
224+
139225
- Default: `true`
140226

141227
The warnings found will always be emitted, to disable set to `false`.
142228

143229
#### `failOnError`
144230

145-
- Type: `Boolean`
231+
- Type:
232+
233+
```ts
234+
type failOnError = boolean;
235+
```
236+
146237
- Default: `true`
147238

148239
Will cause the module build to fail if there are any errors, to disable set to `false`.
149240

150241
#### `failOnWarning`
151242

152-
- Type: `Boolean`
243+
- Type:
244+
245+
```ts
246+
type failOnWarning = boolean;
247+
```
248+
153249
- Default: `false`
154250

155251
Will cause the module build to fail if there are any warnings, if set to `true`.
156252

157253
#### `quiet`
158254

159-
- Type: `Boolean`
255+
- Type:
256+
257+
```ts
258+
type quiet = boolean;
259+
```
260+
160261
- Default: `false`
161262

162263
Will process and report errors only and ignore warnings, if set to `true`.
163264

164265
#### `outputReport`
165266

166-
- Type: `Boolean|Object`
267+
- Type:
268+
269+
```ts
270+
type outputReport =
271+
| boolean
272+
| {
273+
filePath?: string | undefined;
274+
formatter?:
275+
| (
276+
| string
277+
| ((
278+
results: Array<import('stylelint').LintResult>
279+
) => string)
280+
)
281+
| undefined;
282+
};
283+
```
284+
167285
- Default: `false`
168286

169287
Write the output of the errors to a file, for example a `json` file for use for reporting.

declarations/StylelintError.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
export default StylelintError;
2-
declare class StylelintError extends Error {}
2+
declare class StylelintError extends Error {
3+
/**
4+
* @param {string=} messages
5+
*/
6+
constructor(messages?: string | undefined);
7+
stack: string;
8+
}

declarations/getStylelint.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ export type Stylelint = import('postcss').PluginCreator<
3030
createLinter: (
3131
options: import('stylelint').LinterOptions
3232
) => import('stylelint').InternalApi;
33+
resolveConfig: (
34+
filePath: string,
35+
options?:
36+
| Pick<
37+
import('stylelint').LinterOptions,
38+
'cwd' | 'config' | 'configFile' | 'configBasedir'
39+
>
40+
| undefined
41+
) => Promise<import('stylelint').Config | undefined>;
3342
utils: {
3443
report: (problem: import('stylelint').Problem) => void;
3544
ruleMessages: <

declarations/linter.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ export type Stylelint = import('postcss').PluginCreator<
3636
createLinter: (
3737
options: import('stylelint').LinterOptions
3838
) => import('stylelint').InternalApi;
39+
resolveConfig: (
40+
filePath: string,
41+
options?:
42+
| Pick<
43+
import('stylelint').LinterOptions,
44+
'cwd' | 'config' | 'configFile' | 'configBasedir'
45+
>
46+
| undefined
47+
) => Promise<import('stylelint').Config | undefined>;
3948
utils: {
4049
report: (problem: import('stylelint').Problem) => void;
4150
ruleMessages: <

declarations/options.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ export type stylelint = import('postcss').PluginCreator<
5959
createLinter: (
6060
options: import('stylelint').LinterOptions
6161
) => import('stylelint').InternalApi;
62+
resolveConfig: (
63+
filePath: string,
64+
options?:
65+
| Pick<
66+
import('stylelint').LinterOptions,
67+
'cwd' | 'config' | 'configFile' | 'configBasedir'
68+
>
69+
| undefined
70+
) => Promise<import('stylelint').Config | undefined>;
6271
utils: {
6372
report: (problem: import('stylelint').Problem) => void;
6473
ruleMessages: <

declarations/worker.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ export type Stylelint = import('postcss').PluginCreator<
2121
createLinter: (
2222
options: import('stylelint').LinterOptions
2323
) => import('stylelint').InternalApi;
24+
resolveConfig: (
25+
filePath: string,
26+
options?:
27+
| Pick<
28+
import('stylelint').LinterOptions,
29+
'cwd' | 'config' | 'configFile' | 'configBasedir'
30+
>
31+
| undefined
32+
) => Promise<import('stylelint').Config | undefined>;
2433
utils: {
2534
report: (problem: import('stylelint').Problem) => void;
2635
ruleMessages: <

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2+
collectCoverageFrom: ['src/**/*.js'],
23
collectCoverage: true,
34
testEnvironment: 'node',
45
testTimeout: 60000,
5-
transformIgnorePatterns: ['node_modules/(?!(arrify)/)'],
66
};

0 commit comments

Comments
 (0)