stylelint-webpack-plugin 2.2.0 → 2.2.1
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/README.md +1 -1
- package/declarations/index.d.ts +3 -3
- package/declarations/utils.d.ts +5 -2
- package/dist/index.js +24 -59
- package/dist/utils.js +4 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ A string indicating the root of your files.
|
|
|
64
64
|
### `exclude`
|
|
65
65
|
|
|
66
66
|
- Type: `String|Array[String]`
|
|
67
|
-
- Default: `'node_modules'`
|
|
67
|
+
- Default: `['node_modules', compiler.options.output.path]`
|
|
68
68
|
|
|
69
69
|
Specify the files and/or directories to exclude. Must be relative to `options.context`.
|
|
70
70
|
|
package/declarations/index.d.ts
CHANGED
|
@@ -33,12 +33,12 @@ declare class StylelintWebpackPlugin {
|
|
|
33
33
|
*/
|
|
34
34
|
getContext(compiler: Compiler): string;
|
|
35
35
|
/**
|
|
36
|
-
* @param {string[]} glob
|
|
37
36
|
* @param {Compiler} compiler
|
|
38
|
-
* @param {
|
|
37
|
+
* @param {string[]} wanted
|
|
38
|
+
* @param {string[]} exclude
|
|
39
39
|
* @returns {string[]}
|
|
40
40
|
*/
|
|
41
|
-
getFiles(
|
|
41
|
+
getFiles(compiler: Compiler, wanted: string[], exclude: string[]): string[];
|
|
42
42
|
/**
|
|
43
43
|
* @param {Map<string, null | FileSystemInfoEntry | "ignore">} fileTimestamps
|
|
44
44
|
* @returns {string[]}
|
package/declarations/utils.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {string|string[]} files
|
|
2
|
+
* @param {string|(string|undefined)[]} files
|
|
3
3
|
* @param {string} context
|
|
4
4
|
* @returns {string[]}
|
|
5
5
|
*/
|
|
6
|
-
export function parseFiles(
|
|
6
|
+
export function parseFiles(
|
|
7
|
+
files: string | (string | undefined)[],
|
|
8
|
+
context: string
|
|
9
|
+
): string[];
|
|
7
10
|
/**
|
|
8
11
|
* @param {string|string[]} patterns
|
|
9
12
|
* @param {string|string[]} extensions
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var _path = require("path");
|
|
|
9
9
|
|
|
10
10
|
var _arrify = _interopRequireDefault(require("arrify"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _globby = _interopRequireDefault(require("globby"));
|
|
13
13
|
|
|
14
14
|
var _micromatch = require("micromatch");
|
|
15
15
|
|
|
@@ -89,12 +89,12 @@ class StylelintWebpackPlugin {
|
|
|
89
89
|
|
|
90
90
|
const context = this.getContext(compiler);
|
|
91
91
|
const options = { ...this.options,
|
|
92
|
-
exclude: (0, _utils.parseFiles)(this.options.exclude || [], context),
|
|
92
|
+
exclude: (0, _utils.parseFiles)(this.options.exclude || ['**/node_modules/**', compiler.options.output.path], context),
|
|
93
93
|
extensions: (0, _arrify.default)(this.options.extensions),
|
|
94
94
|
files: (0, _utils.parseFiles)(this.options.files || '', context)
|
|
95
95
|
};
|
|
96
96
|
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions);
|
|
97
|
-
const exclude = (0, _utils.parseFoldersToGlobs)(
|
|
97
|
+
const exclude = (0, _utils.parseFoldersToGlobs)(options.exclude);
|
|
98
98
|
compiler.hooks.thisCompilation.tap(this.key, compilation => {
|
|
99
99
|
/** @type {import('./linter').Linter} */
|
|
100
100
|
let lint;
|
|
@@ -115,29 +115,15 @@ class StylelintWebpackPlugin {
|
|
|
115
115
|
compilation.errors.push(e);
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
/** @type {string[]} */
|
|
119
118
|
|
|
119
|
+
compilation.hooks.finishModules.tap(this.key, () => {
|
|
120
|
+
const files = this.getFiles(compiler, wanted, exclude);
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
compilation.hooks.succeedModule.tap(this.key, module => {
|
|
124
|
-
const filteredFiles = this.getFiles(wanted, compiler, module).filter(file => !files.includes(file) && (0, _micromatch.isMatch)(file, wanted, {
|
|
125
|
-
dot: true
|
|
126
|
-
}) && !(0, _micromatch.isMatch)(file, exclude, {
|
|
127
|
-
dot: true
|
|
128
|
-
}));
|
|
129
|
-
|
|
130
|
-
for (const file of filteredFiles) {
|
|
131
|
-
files.push(file);
|
|
132
|
-
|
|
133
|
-
if (threads > 1) {
|
|
122
|
+
if (threads > 1) {
|
|
123
|
+
for (const file of files) {
|
|
134
124
|
lint((0, _utils.parseFiles)(file, context));
|
|
135
125
|
}
|
|
136
|
-
}
|
|
137
|
-
}); // Lint all files added
|
|
138
|
-
|
|
139
|
-
compilation.hooks.finishModules.tap(this.key, () => {
|
|
140
|
-
if (files.length > 0 && threads <= 1) {
|
|
126
|
+
} else if (files.length > 0) {
|
|
141
127
|
lint((0, _utils.parseFiles)(files, context));
|
|
142
128
|
}
|
|
143
129
|
}); // await and interpret results
|
|
@@ -192,59 +178,38 @@ class StylelintWebpackPlugin {
|
|
|
192
178
|
return this.options.context;
|
|
193
179
|
}
|
|
194
180
|
/**
|
|
195
|
-
* @param {string[]} glob
|
|
196
181
|
* @param {Compiler} compiler
|
|
197
|
-
* @param {
|
|
182
|
+
* @param {string[]} wanted
|
|
183
|
+
* @param {string[]} exclude
|
|
198
184
|
* @returns {string[]}
|
|
199
185
|
*/
|
|
200
186
|
// eslint-disable-next-line no-unused-vars
|
|
201
187
|
|
|
202
188
|
|
|
203
|
-
getFiles(
|
|
204
|
-
// TODO: how to get module dependencies on css files?
|
|
205
|
-
// maybe implemented on next major version v3
|
|
206
|
-
// Temporaly lint all css files on start webpack
|
|
207
|
-
// on watch lint only modified files
|
|
208
|
-
// on webpack 5 not safe to use `module.buildInfo.snapshot`
|
|
209
|
-
// on webpack `module.buildInfo.fileDependencies` not working correclty
|
|
210
|
-
// webpack 5
|
|
211
|
-
|
|
212
|
-
/*
|
|
213
|
-
if (
|
|
214
|
-
module.buildInfo &&
|
|
215
|
-
module.buildInfo.snapshot &&
|
|
216
|
-
module.buildInfo.snapshot.fileTimestamps
|
|
217
|
-
) {
|
|
218
|
-
files = this.getChangedFiles(module.buildInfo.snapshot.fileTimestamps);
|
|
219
|
-
}
|
|
220
|
-
// webpack 4
|
|
221
|
-
else if (module.buildInfo && module.buildInfo.fileDependencies) {
|
|
222
|
-
files = Array.from(module.buildInfo.fileDependencies);
|
|
223
|
-
if (compiler.fileTimestamps && compiler.fileTimestamps.size > 0) {
|
|
224
|
-
const fileDependencies = new Map();
|
|
225
|
-
for (const [filename, timestamp] of compiler.fileTimestamps.entries()) {
|
|
226
|
-
if (files.includes(filename)) {
|
|
227
|
-
fileDependencies.set(filename, timestamp);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
files = this.getChangedFiles(fileDependencies);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
*/
|
|
189
|
+
getFiles(compiler, wanted, exclude) {
|
|
234
190
|
// webpack 5
|
|
235
191
|
if (compiler.modifiedFiles) {
|
|
236
|
-
return Array.from(compiler.modifiedFiles)
|
|
192
|
+
return Array.from(compiler.modifiedFiles).filter(file => (0, _micromatch.isMatch)(file, wanted, {
|
|
193
|
+
dot: true
|
|
194
|
+
}) && !(0, _micromatch.isMatch)(file, exclude, {
|
|
195
|
+
dot: true
|
|
196
|
+
}));
|
|
237
197
|
} // webpack 4
|
|
238
198
|
|
|
239
199
|
/* istanbul ignore next */
|
|
240
200
|
|
|
241
201
|
|
|
242
202
|
if (compiler.fileTimestamps && compiler.fileTimestamps.size > 0) {
|
|
243
|
-
return this.getChangedFiles(compiler.fileTimestamps)
|
|
203
|
+
return this.getChangedFiles(compiler.fileTimestamps).filter(file => (0, _micromatch.isMatch)(file, wanted, {
|
|
204
|
+
dot: true
|
|
205
|
+
}) && !(0, _micromatch.isMatch)(file, exclude, {
|
|
206
|
+
dot: true
|
|
207
|
+
}));
|
|
244
208
|
}
|
|
245
209
|
|
|
246
|
-
return
|
|
247
|
-
dot: true
|
|
210
|
+
return _globby.default.sync(wanted, {
|
|
211
|
+
dot: true,
|
|
212
|
+
ignore: exclude
|
|
248
213
|
});
|
|
249
214
|
}
|
|
250
215
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -21,12 +21,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
// @ts-ignore
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @param {string|string[]} files
|
|
24
|
+
* @param {string|(string|undefined)[]} files
|
|
25
25
|
* @param {string} context
|
|
26
26
|
* @returns {string[]}
|
|
27
27
|
*/
|
|
28
28
|
function parseFiles(files, context) {
|
|
29
|
-
return (0, _arrify.default)(files).
|
|
29
|
+
return (0, _arrify.default)(files).filter((
|
|
30
|
+
/** @type {string} */
|
|
31
|
+
file) => typeof file === 'string').map((
|
|
30
32
|
/** @type {string} */
|
|
31
33
|
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file)));
|
|
32
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-webpack-plugin",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A Stylelint plugin for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/stylelint-webpack-plugin",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@types/stylelint": "^13.13.0",
|
|
50
50
|
"arrify": "^2.0.1",
|
|
51
|
-
"fast-glob": "^3.2.5",
|
|
52
51
|
"jest-worker": "^27.0.2",
|
|
52
|
+
"globby": "^11.0.4",
|
|
53
53
|
"micromatch": "^4.0.4",
|
|
54
54
|
"normalize-path": "^3.0.0",
|
|
55
55
|
"schema-utils": "^3.0.0"
|