stylelint-webpack-plugin 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +199 -199
- package/dist/StylelintError.js +4 -10
- package/dist/getStylelint.js +47 -40
- package/dist/index.js +90 -71
- package/dist/linter.js +67 -61
- package/dist/options.js +40 -41
- package/dist/options.json +80 -80
- package/dist/utils.js +33 -40
- package/dist/worker.js +5 -5
- package/package.json +23 -23
- package/types/StylelintError.d.ts +8 -0
- package/{declarations → types}/getStylelint.d.ts +35 -13
- package/{declarations → types}/index.d.ts +22 -11
- package/{declarations → types}/linter.d.ts +44 -15
- package/{declarations → types}/options.d.ts +47 -38
- package/{declarations → types}/utils.d.ts +5 -0
- package/{declarations → types}/worker.d.ts +9 -0
- package/declarations/StylelintError.d.ts +0 -2
- package/declarations/cjs.d.ts +0 -3
- package/dist/cjs.js +0 -5
package/LICENSE
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
Copyright JS Foundation and other contributors
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
'Software'), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright JS Foundation and other contributors
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<a href="https://github.com/stylelint/stylelint"><img width="200" height="200" src="https://cdn.worldvectorlogo.com/logos/stylelint.svg"></a>
|
|
3
|
-
<a href="https://github.com/webpack/webpack"><img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"></a>
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
[![npm][npm]][npm-url]
|
|
7
|
-
[![node][node]][node-url]
|
|
8
|
-
[![deps][deps]][deps-url]
|
|
9
|
-
[![tests][tests]][tests-url]
|
|
10
|
-
[![coverage][cover]][cover-url]
|
|
11
|
-
[![chat][chat]][chat-url]
|
|
12
|
-
[![size][size]][size-url]
|
|
13
|
-
|
|
14
|
-
# stylelint-webpack-plugin
|
|
15
|
-
|
|
16
|
-
> A Stylelint plugin for webpack
|
|
17
|
-
|
|
18
|
-
## Install
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install stylelint-webpack-plugin@2 --save-dev
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
**Note**: You also need to install `stylelint` from npm, if you haven't already:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install stylelint --save-dev
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**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.
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
In your webpack configuration:
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
const StylelintPlugin = require('stylelint-webpack-plugin');
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
// ...
|
|
41
|
-
plugins: [new StylelintPlugin(options)],
|
|
42
|
-
// ...
|
|
43
|
-
};
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Options
|
|
47
|
-
|
|
48
|
-
See [stylelint's options](http://stylelint.io/user-guide/node-api/#options) for the complete list of options available. These options are passed through to the `stylelint` directly.
|
|
49
|
-
|
|
50
|
-
### `configFile`
|
|
51
|
-
|
|
52
|
-
- Type: `String`
|
|
53
|
-
- Default: `undefined`
|
|
54
|
-
|
|
55
|
-
Specify the config file location to be used by `stylelint`.
|
|
56
|
-
|
|
57
|
-
**Note:** By default this is [handled by `stylelint`](http://stylelint.io/user-guide/configuration/).
|
|
58
|
-
|
|
59
|
-
### `context`
|
|
60
|
-
|
|
61
|
-
- Type: `String`
|
|
62
|
-
- Default: `compiler.context`
|
|
63
|
-
|
|
64
|
-
A string indicating the root of your files.
|
|
65
|
-
|
|
66
|
-
### `exclude`
|
|
67
|
-
|
|
68
|
-
- Type: `String|Array[String]`
|
|
69
|
-
- Default: `['node_modules', compiler.options.output.path]`
|
|
70
|
-
|
|
71
|
-
Specify the files and/or directories to exclude. Must be relative to `options.context`.
|
|
72
|
-
|
|
73
|
-
### `extensions`
|
|
74
|
-
|
|
75
|
-
- Type: `String|Array[String]`
|
|
76
|
-
- Default: `['css', 'scss', 'sass']`
|
|
77
|
-
|
|
78
|
-
Specify extensions that should be checked.
|
|
79
|
-
|
|
80
|
-
### `files`
|
|
81
|
-
|
|
82
|
-
- Type: `String|Array[String]`
|
|
83
|
-
- Default: `null`
|
|
84
|
-
|
|
85
|
-
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`.
|
|
86
|
-
|
|
87
|
-
### `fix`
|
|
88
|
-
|
|
89
|
-
- Type: `Boolean`
|
|
90
|
-
- Default: `false`
|
|
91
|
-
|
|
92
|
-
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/cli#autofixing-errors) docs.
|
|
93
|
-
|
|
94
|
-
### `formatter`
|
|
95
|
-
|
|
96
|
-
- Type: `String|Function`
|
|
97
|
-
- Default: `'string'`
|
|
98
|
-
|
|
99
|
-
Specify the formatter that you would like to use to format your results. See [formatter option](https://stylelint.io/user-guide/node-api#formatter).
|
|
100
|
-
|
|
101
|
-
### `lintDirtyModulesOnly`
|
|
102
|
-
|
|
103
|
-
- Type: `Boolean`
|
|
104
|
-
- Default: `false`
|
|
105
|
-
|
|
106
|
-
Lint only changed files, skip lint on start.
|
|
107
|
-
|
|
108
|
-
### `stylelintPath`
|
|
109
|
-
|
|
110
|
-
- Type: `String`
|
|
111
|
-
- Default: `stylelint`
|
|
112
|
-
|
|
113
|
-
Path to `stylelint` instance that will be used for linting.
|
|
114
|
-
|
|
115
|
-
### `threads`
|
|
116
|
-
|
|
117
|
-
- Type: `Boolean | Number`
|
|
118
|
-
- Default: `false`
|
|
119
|
-
|
|
120
|
-
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.
|
|
121
|
-
|
|
122
|
-
### Errors and Warning
|
|
123
|
-
|
|
124
|
-
**By default the plugin will auto adjust error reporting depending on stylelint errors/warnings counts.**
|
|
125
|
-
You can still force this behavior by using `emitError` **or** `emitWarning` options:
|
|
126
|
-
|
|
127
|
-
#### `emitError`
|
|
128
|
-
|
|
129
|
-
- Type: `Boolean`
|
|
130
|
-
- Default: `false`
|
|
131
|
-
|
|
132
|
-
The errors found will always be emitted, to disable set to `false`.
|
|
133
|
-
|
|
134
|
-
#### `emitWarning`
|
|
135
|
-
|
|
136
|
-
- Type: `Boolean`
|
|
137
|
-
- Default: `false`
|
|
138
|
-
|
|
139
|
-
The warnings found will always be emitted, to disable set to `false`.
|
|
140
|
-
|
|
141
|
-
#### `failOnError`
|
|
142
|
-
|
|
143
|
-
- Type: `Boolean`
|
|
144
|
-
- Default: `false`
|
|
145
|
-
|
|
146
|
-
Will cause the module build to fail if there are any errors, to disable set to `false`.
|
|
147
|
-
|
|
148
|
-
#### `failOnWarning`
|
|
149
|
-
|
|
150
|
-
- Type: `Boolean`
|
|
151
|
-
- Default: `false`
|
|
152
|
-
|
|
153
|
-
Will cause the module build to fail if there are any warnings, if set to `true`.
|
|
154
|
-
|
|
155
|
-
#### `quiet`
|
|
156
|
-
|
|
157
|
-
- Type: `Boolean`
|
|
158
|
-
- Default: `false`
|
|
159
|
-
|
|
160
|
-
Will process and report errors only and ignore warnings, if set to `true`.
|
|
161
|
-
|
|
162
|
-
#### `outputReport`
|
|
163
|
-
|
|
164
|
-
- Type: `Boolean|Object`
|
|
165
|
-
- Default: `false`
|
|
166
|
-
|
|
167
|
-
Write the output of the errors to a file, for example a `json` file for use for reporting.
|
|
168
|
-
The `filePath` is relative to the webpack config: `output.path`.
|
|
169
|
-
You can pass in a different formatter for the output file, if none is passed in the default/configured formatter will be used.
|
|
170
|
-
|
|
171
|
-
```js
|
|
172
|
-
{
|
|
173
|
-
filePath: 'path/to/file';
|
|
174
|
-
formatter: 'json';
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## Changelog
|
|
179
|
-
|
|
180
|
-
[Changelog](CHANGELOG.md)
|
|
181
|
-
|
|
182
|
-
## License
|
|
183
|
-
|
|
184
|
-
[MIT](./LICENSE)
|
|
185
|
-
|
|
186
|
-
[npm]: https://img.shields.io/npm/v/stylelint-webpack-plugin/2x.svg
|
|
187
|
-
[npm-url]: https://npmjs.com/package/stylelint-webpack-plugin/v/2x
|
|
188
|
-
[node]: https://img.shields.io/node/v/stylelint-webpack-plugin/2x.svg
|
|
189
|
-
[node-url]: https://nodejs.org
|
|
190
|
-
[deps]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin.svg
|
|
191
|
-
[deps-url]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin
|
|
192
|
-
[tests]: https://github.com/webpack-contrib/stylelint-webpack-plugin/workflows/stylelint-webpack-plugin/badge.svg?branch=2.x
|
|
193
|
-
[tests-url]: https://github.com/webpack-contrib/stylelint-webpack-plugin/actions
|
|
194
|
-
[cover]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin/branch/2.x/graph/badge.svg
|
|
195
|
-
[cover-url]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin/branch/2.x
|
|
196
|
-
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
197
|
-
[chat-url]: https://gitter.im/webpack/webpack
|
|
198
|
-
[size]: https://packagephobia.now.sh/badge?p=stylelint-webpack-plugin
|
|
199
|
-
[size-url]: https://packagephobia.now.sh/result?p=stylelint-webpack-plugin
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://github.com/stylelint/stylelint"><img width="200" height="200" src="https://cdn.worldvectorlogo.com/logos/stylelint.svg"></a>
|
|
3
|
+
<a href="https://github.com/webpack/webpack"><img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"></a>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
[![npm][npm]][npm-url]
|
|
7
|
+
[![node][node]][node-url]
|
|
8
|
+
[![deps][deps]][deps-url]
|
|
9
|
+
[![tests][tests]][tests-url]
|
|
10
|
+
[![coverage][cover]][cover-url]
|
|
11
|
+
[![chat][chat]][chat-url]
|
|
12
|
+
[![size][size]][size-url]
|
|
13
|
+
|
|
14
|
+
# stylelint-webpack-plugin
|
|
15
|
+
|
|
16
|
+
> A Stylelint plugin for webpack
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install stylelint-webpack-plugin@2 --save-dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Note**: You also need to install `stylelint` from npm, if you haven't already:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install stylelint --save-dev
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**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.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
In your webpack configuration:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const StylelintPlugin = require('stylelint-webpack-plugin');
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
// ...
|
|
41
|
+
plugins: [new StylelintPlugin(options)],
|
|
42
|
+
// ...
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Options
|
|
47
|
+
|
|
48
|
+
See [stylelint's options](http://stylelint.io/user-guide/node-api/#options) for the complete list of options available. These options are passed through to the `stylelint` directly.
|
|
49
|
+
|
|
50
|
+
### `configFile`
|
|
51
|
+
|
|
52
|
+
- Type: `String`
|
|
53
|
+
- Default: `undefined`
|
|
54
|
+
|
|
55
|
+
Specify the config file location to be used by `stylelint`.
|
|
56
|
+
|
|
57
|
+
**Note:** By default this is [handled by `stylelint`](http://stylelint.io/user-guide/configuration/).
|
|
58
|
+
|
|
59
|
+
### `context`
|
|
60
|
+
|
|
61
|
+
- Type: `String`
|
|
62
|
+
- Default: `compiler.context`
|
|
63
|
+
|
|
64
|
+
A string indicating the root of your files.
|
|
65
|
+
|
|
66
|
+
### `exclude`
|
|
67
|
+
|
|
68
|
+
- Type: `String|Array[String]`
|
|
69
|
+
- Default: `['node_modules', compiler.options.output.path]`
|
|
70
|
+
|
|
71
|
+
Specify the files and/or directories to exclude. Must be relative to `options.context`.
|
|
72
|
+
|
|
73
|
+
### `extensions`
|
|
74
|
+
|
|
75
|
+
- Type: `String|Array[String]`
|
|
76
|
+
- Default: `['css', 'scss', 'sass']`
|
|
77
|
+
|
|
78
|
+
Specify extensions that should be checked.
|
|
79
|
+
|
|
80
|
+
### `files`
|
|
81
|
+
|
|
82
|
+
- Type: `String|Array[String]`
|
|
83
|
+
- Default: `null`
|
|
84
|
+
|
|
85
|
+
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`.
|
|
86
|
+
|
|
87
|
+
### `fix`
|
|
88
|
+
|
|
89
|
+
- Type: `Boolean`
|
|
90
|
+
- Default: `false`
|
|
91
|
+
|
|
92
|
+
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/cli#autofixing-errors) docs.
|
|
93
|
+
|
|
94
|
+
### `formatter`
|
|
95
|
+
|
|
96
|
+
- Type: `String|Function`
|
|
97
|
+
- Default: `'string'`
|
|
98
|
+
|
|
99
|
+
Specify the formatter that you would like to use to format your results. See [formatter option](https://stylelint.io/user-guide/node-api#formatter).
|
|
100
|
+
|
|
101
|
+
### `lintDirtyModulesOnly`
|
|
102
|
+
|
|
103
|
+
- Type: `Boolean`
|
|
104
|
+
- Default: `false`
|
|
105
|
+
|
|
106
|
+
Lint only changed files, skip lint on start.
|
|
107
|
+
|
|
108
|
+
### `stylelintPath`
|
|
109
|
+
|
|
110
|
+
- Type: `String`
|
|
111
|
+
- Default: `stylelint`
|
|
112
|
+
|
|
113
|
+
Path to `stylelint` instance that will be used for linting.
|
|
114
|
+
|
|
115
|
+
### `threads`
|
|
116
|
+
|
|
117
|
+
- Type: `Boolean | Number`
|
|
118
|
+
- Default: `false`
|
|
119
|
+
|
|
120
|
+
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.
|
|
121
|
+
|
|
122
|
+
### Errors and Warning
|
|
123
|
+
|
|
124
|
+
**By default the plugin will auto adjust error reporting depending on stylelint errors/warnings counts.**
|
|
125
|
+
You can still force this behavior by using `emitError` **or** `emitWarning` options:
|
|
126
|
+
|
|
127
|
+
#### `emitError`
|
|
128
|
+
|
|
129
|
+
- Type: `Boolean`
|
|
130
|
+
- Default: `false`
|
|
131
|
+
|
|
132
|
+
The errors found will always be emitted, to disable set to `false`.
|
|
133
|
+
|
|
134
|
+
#### `emitWarning`
|
|
135
|
+
|
|
136
|
+
- Type: `Boolean`
|
|
137
|
+
- Default: `false`
|
|
138
|
+
|
|
139
|
+
The warnings found will always be emitted, to disable set to `false`.
|
|
140
|
+
|
|
141
|
+
#### `failOnError`
|
|
142
|
+
|
|
143
|
+
- Type: `Boolean`
|
|
144
|
+
- Default: `false`
|
|
145
|
+
|
|
146
|
+
Will cause the module build to fail if there are any errors, to disable set to `false`.
|
|
147
|
+
|
|
148
|
+
#### `failOnWarning`
|
|
149
|
+
|
|
150
|
+
- Type: `Boolean`
|
|
151
|
+
- Default: `false`
|
|
152
|
+
|
|
153
|
+
Will cause the module build to fail if there are any warnings, if set to `true`.
|
|
154
|
+
|
|
155
|
+
#### `quiet`
|
|
156
|
+
|
|
157
|
+
- Type: `Boolean`
|
|
158
|
+
- Default: `false`
|
|
159
|
+
|
|
160
|
+
Will process and report errors only and ignore warnings, if set to `true`.
|
|
161
|
+
|
|
162
|
+
#### `outputReport`
|
|
163
|
+
|
|
164
|
+
- Type: `Boolean|Object`
|
|
165
|
+
- Default: `false`
|
|
166
|
+
|
|
167
|
+
Write the output of the errors to a file, for example a `json` file for use for reporting.
|
|
168
|
+
The `filePath` is relative to the webpack config: `output.path`.
|
|
169
|
+
You can pass in a different formatter for the output file, if none is passed in the default/configured formatter will be used.
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
{
|
|
173
|
+
filePath: 'path/to/file';
|
|
174
|
+
formatter: 'json';
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Changelog
|
|
179
|
+
|
|
180
|
+
[Changelog](CHANGELOG.md)
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
[MIT](./LICENSE)
|
|
185
|
+
|
|
186
|
+
[npm]: https://img.shields.io/npm/v/stylelint-webpack-plugin/2x.svg
|
|
187
|
+
[npm-url]: https://npmjs.com/package/stylelint-webpack-plugin/v/2x
|
|
188
|
+
[node]: https://img.shields.io/node/v/stylelint-webpack-plugin/2x.svg
|
|
189
|
+
[node-url]: https://nodejs.org
|
|
190
|
+
[deps]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin.svg
|
|
191
|
+
[deps-url]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin
|
|
192
|
+
[tests]: https://github.com/webpack-contrib/stylelint-webpack-plugin/workflows/stylelint-webpack-plugin/badge.svg?branch=2.x
|
|
193
|
+
[tests-url]: https://github.com/webpack-contrib/stylelint-webpack-plugin/actions
|
|
194
|
+
[cover]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin/branch/2.x/graph/badge.svg
|
|
195
|
+
[cover-url]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin/branch/2.x
|
|
196
|
+
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
197
|
+
[chat-url]: https://gitter.im/webpack/webpack
|
|
198
|
+
[size]: https://packagephobia.now.sh/badge?p=stylelint-webpack-plugin
|
|
199
|
+
[size-url]: https://packagephobia.now.sh/result?p=stylelint-webpack-plugin
|
package/dist/StylelintError.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
3
|
class StylelintError extends Error {
|
|
9
|
-
/**
|
|
10
|
-
* @param {string=} messages
|
|
4
|
+
/**
|
|
5
|
+
* @param {string=} messages
|
|
11
6
|
*/
|
|
12
7
|
constructor(messages) {
|
|
13
|
-
super(messages);
|
|
8
|
+
super(`[stylelint] ${messages}`);
|
|
14
9
|
this.name = 'StylelintError';
|
|
15
10
|
this.stack = '';
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
exports.default = _default;
|
|
15
|
+
module.exports = StylelintError;
|
package/dist/getStylelint.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = getStylelint;
|
|
3
|
+
const {
|
|
4
|
+
cpus
|
|
5
|
+
} = require('os');
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
const {
|
|
8
|
+
Worker: JestWorker
|
|
9
|
+
} = require('jest-worker'); // @ts-ignore
|
|
9
10
|
|
|
10
|
-
var _jestWorker = require("jest-worker");
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const {
|
|
13
|
+
setup,
|
|
14
|
+
lintFiles
|
|
15
|
+
} = require('./worker');
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
const {
|
|
18
|
+
jsonStringifyReplacerSortKeys
|
|
19
|
+
} = require('./utils');
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
const {
|
|
22
|
+
getStylelintOptions
|
|
23
|
+
} = require('./options');
|
|
24
|
+
/** @type {{[key: string]: any}} */
|
|
17
25
|
|
|
18
|
-
// @ts-ignore
|
|
19
26
|
|
|
20
|
-
/** @type {{[key: string]: any}} */
|
|
21
27
|
const cache = {};
|
|
22
28
|
/** @typedef {import('stylelint')} Stylelint */
|
|
23
29
|
|
|
@@ -29,29 +35,31 @@ const cache = {};
|
|
|
29
35
|
|
|
30
36
|
/** @typedef {(files: string|string[]) => Promise<LintResult[]>} LintTask */
|
|
31
37
|
|
|
32
|
-
/** @typedef {
|
|
38
|
+
/** @typedef {{api: import('stylelint').InternalApi, stylelint: Stylelint, lintFiles: LintTask, cleanup: AsyncTask, threads: number, }} Linter */
|
|
33
39
|
|
|
34
|
-
/** @typedef {
|
|
40
|
+
/** @typedef {JestWorker & {lintFiles: LintTask}} Worker */
|
|
35
41
|
|
|
36
|
-
/**
|
|
37
|
-
* @param {Options} options
|
|
38
|
-
* @returns {Linter}
|
|
42
|
+
/**
|
|
43
|
+
* @param {Options} options
|
|
44
|
+
* @returns {Linter}
|
|
39
45
|
*/
|
|
40
46
|
|
|
41
47
|
function loadStylelint(options) {
|
|
42
|
-
const
|
|
48
|
+
const stylelintOptions = getStylelintOptions(options);
|
|
49
|
+
const stylelint = setup(options, stylelintOptions);
|
|
43
50
|
return {
|
|
44
51
|
stylelint,
|
|
45
|
-
|
|
52
|
+
api: stylelint.createLinter(stylelintOptions),
|
|
53
|
+
lintFiles,
|
|
46
54
|
cleanup: async () => {},
|
|
47
55
|
threads: 1
|
|
48
56
|
};
|
|
49
57
|
}
|
|
50
|
-
/**
|
|
51
|
-
* @param {string|undefined} key
|
|
52
|
-
* @param {number} poolSize
|
|
53
|
-
* @param {Options} options
|
|
54
|
-
* @returns {Linter}
|
|
58
|
+
/**
|
|
59
|
+
* @param {string|undefined} key
|
|
60
|
+
* @param {number} poolSize
|
|
61
|
+
* @param {Options} options
|
|
62
|
+
* @returns {Linter}
|
|
55
63
|
*/
|
|
56
64
|
|
|
57
65
|
|
|
@@ -63,15 +71,12 @@ function loadStylelintThreaded(key, poolSize, options) {
|
|
|
63
71
|
const workerOptions = {
|
|
64
72
|
enableWorkerThreads: true,
|
|
65
73
|
numWorkers: poolSize,
|
|
66
|
-
setupArgs: [options,
|
|
74
|
+
setupArgs: [options, getStylelintOptions(options)]
|
|
67
75
|
};
|
|
68
76
|
const local = loadStylelint(options);
|
|
69
|
-
/** @type {Worker?} */
|
|
70
|
-
// prettier-ignore
|
|
71
|
-
|
|
72
77
|
let worker =
|
|
73
|
-
/** @type {Worker} */
|
|
74
|
-
new
|
|
78
|
+
/** @type {Worker?} */
|
|
79
|
+
new JestWorker(source, workerOptions);
|
|
75
80
|
/** @type {Linter} */
|
|
76
81
|
|
|
77
82
|
const context = { ...local,
|
|
@@ -94,10 +99,10 @@ function loadStylelintThreaded(key, poolSize, options) {
|
|
|
94
99
|
};
|
|
95
100
|
return context;
|
|
96
101
|
}
|
|
97
|
-
/**
|
|
98
|
-
* @param {string|undefined} key
|
|
99
|
-
* @param {Options} options
|
|
100
|
-
* @returns {Linter}
|
|
102
|
+
/**
|
|
103
|
+
* @param {string|undefined} key
|
|
104
|
+
* @param {Options} options
|
|
105
|
+
* @returns {Linter}
|
|
101
106
|
*/
|
|
102
107
|
|
|
103
108
|
|
|
@@ -105,7 +110,7 @@ function getStylelint(key, {
|
|
|
105
110
|
threads,
|
|
106
111
|
...options
|
|
107
112
|
}) {
|
|
108
|
-
const max = typeof threads !== 'number' ? threads ?
|
|
113
|
+
const max = typeof threads !== 'number' ? threads ? cpus().length - 1 : 1 : threads;
|
|
109
114
|
const cacheKey = getCacheKey(key, {
|
|
110
115
|
threads,
|
|
111
116
|
...options
|
|
@@ -117,10 +122,10 @@ function getStylelint(key, {
|
|
|
117
122
|
|
|
118
123
|
return cache[cacheKey];
|
|
119
124
|
}
|
|
120
|
-
/**
|
|
121
|
-
* @param {string|undefined} key
|
|
122
|
-
* @param {Options} options
|
|
123
|
-
* @returns {string}
|
|
125
|
+
/**
|
|
126
|
+
* @param {string|undefined} key
|
|
127
|
+
* @param {Options} options
|
|
128
|
+
* @returns {string}
|
|
124
129
|
*/
|
|
125
130
|
|
|
126
131
|
|
|
@@ -128,5 +133,7 @@ function getCacheKey(key, options) {
|
|
|
128
133
|
return JSON.stringify({
|
|
129
134
|
key,
|
|
130
135
|
options
|
|
131
|
-
},
|
|
132
|
-
}
|
|
136
|
+
}, jsonStringifyReplacerSortKeys);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
module.exports = getStylelint;
|