stylelint-webpack-plugin 2.2.0 → 2.3.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/getStylelint.d.ts +49 -1
- package/declarations/index.d.ts +13 -6
- package/declarations/linter.d.ts +49 -1
- package/declarations/options.d.ts +49 -1
- package/declarations/utils.d.ts +5 -2
- package/declarations/worker.d.ts +49 -1
- package/dist/index.js +29 -62
- package/dist/linter.js +11 -33
- package/dist/utils.js +5 -3
- package/package.json +21 -20
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
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="stylelint" />
|
|
1
2
|
/**
|
|
2
3
|
* @param {string|undefined} key
|
|
3
4
|
* @param {Options} options
|
|
@@ -7,7 +8,54 @@ export default function getStylelint(
|
|
|
7
8
|
key: string | undefined,
|
|
8
9
|
{ threads, ...options }: Options
|
|
9
10
|
): Linter;
|
|
10
|
-
export type Stylelint =
|
|
11
|
+
export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
12
|
+
import('stylelint').PostcssPluginOptions
|
|
13
|
+
> & {
|
|
14
|
+
lint: (
|
|
15
|
+
options: import('stylelint').LinterOptions
|
|
16
|
+
) => Promise<import('stylelint').LinterResult>;
|
|
17
|
+
rules: {
|
|
18
|
+
[k: string]: import('stylelint').Rule<any, any>;
|
|
19
|
+
};
|
|
20
|
+
formatters: {
|
|
21
|
+
[k: string]: import('stylelint').Formatter;
|
|
22
|
+
};
|
|
23
|
+
createPlugin: (
|
|
24
|
+
ruleName: string,
|
|
25
|
+
plugin: import('stylelint').Plugin<any, any>
|
|
26
|
+
) => {
|
|
27
|
+
ruleName: string;
|
|
28
|
+
rule: import('stylelint').Rule<any, any>;
|
|
29
|
+
};
|
|
30
|
+
createLinter: (
|
|
31
|
+
options: import('stylelint').LinterOptions
|
|
32
|
+
) => import('stylelint').InternalApi;
|
|
33
|
+
utils: {
|
|
34
|
+
report: (problem: import('stylelint').Problem) => void;
|
|
35
|
+
ruleMessages: <
|
|
36
|
+
T extends import('stylelint').RuleMessages,
|
|
37
|
+
R extends { [K in keyof T]: T[K] }
|
|
38
|
+
>(
|
|
39
|
+
ruleName: string,
|
|
40
|
+
messages: T
|
|
41
|
+
) => R;
|
|
42
|
+
validateOptions: (
|
|
43
|
+
result: import('stylelint').PostcssResult,
|
|
44
|
+
ruleName: string,
|
|
45
|
+
...optionDescriptions: import('stylelint').RuleOptions[]
|
|
46
|
+
) => boolean;
|
|
47
|
+
checkAgainstRule: <T_1, O extends Object>(
|
|
48
|
+
options: {
|
|
49
|
+
ruleName: string;
|
|
50
|
+
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
51
|
+
root: import('stylelint/node_modules/postcss').Root;
|
|
52
|
+
},
|
|
53
|
+
callback: (
|
|
54
|
+
warning: import('stylelint/node_modules/postcss').Warning
|
|
55
|
+
) => void
|
|
56
|
+
) => void;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
11
59
|
export type LintResult = import('stylelint').LintResult;
|
|
12
60
|
export type Options = import('./options').Options;
|
|
13
61
|
export type AsyncTask = () => Promise<void>;
|
package/declarations/index.d.ts
CHANGED
|
@@ -20,7 +20,11 @@ declare class StylelintWebpackPlugin {
|
|
|
20
20
|
*/
|
|
21
21
|
run(compiler: Compiler): Promise<void>;
|
|
22
22
|
startTime: number;
|
|
23
|
-
|
|
23
|
+
/** @type {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} */
|
|
24
|
+
prevTimestamps: ReadonlyMap<
|
|
25
|
+
string,
|
|
26
|
+
'ignore' | FileSystemInfoEntry | null | undefined
|
|
27
|
+
>;
|
|
24
28
|
/**
|
|
25
29
|
* @param {Compiler} compiler
|
|
26
30
|
* @returns {void}
|
|
@@ -33,17 +37,20 @@ declare class StylelintWebpackPlugin {
|
|
|
33
37
|
*/
|
|
34
38
|
getContext(compiler: Compiler): string;
|
|
35
39
|
/**
|
|
36
|
-
* @param {string[]} glob
|
|
37
40
|
* @param {Compiler} compiler
|
|
38
|
-
* @param {
|
|
41
|
+
* @param {string[]} wanted
|
|
42
|
+
* @param {string[]} exclude
|
|
39
43
|
* @returns {string[]}
|
|
40
44
|
*/
|
|
41
|
-
getFiles(
|
|
45
|
+
getFiles(compiler: Compiler, wanted: string[], exclude: string[]): string[];
|
|
42
46
|
/**
|
|
43
|
-
* @param {
|
|
47
|
+
* @param {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} fileTimestamps
|
|
44
48
|
* @returns {string[]}
|
|
45
49
|
*/
|
|
46
50
|
getChangedFiles(
|
|
47
|
-
fileTimestamps:
|
|
51
|
+
fileTimestamps: ReadonlyMap<
|
|
52
|
+
string,
|
|
53
|
+
'ignore' | FileSystemInfoEntry | null | undefined
|
|
54
|
+
>
|
|
48
55
|
): string[];
|
|
49
56
|
}
|
package/declarations/linter.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="stylelint" />
|
|
1
2
|
/**
|
|
2
3
|
* @param {string|undefined} key
|
|
3
4
|
* @param {Options} options
|
|
@@ -13,7 +14,54 @@ export default function linter(
|
|
|
13
14
|
report: Reporter;
|
|
14
15
|
threads: number;
|
|
15
16
|
};
|
|
16
|
-
export type Stylelint =
|
|
17
|
+
export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
18
|
+
import('stylelint').PostcssPluginOptions
|
|
19
|
+
> & {
|
|
20
|
+
lint: (
|
|
21
|
+
options: import('stylelint').LinterOptions
|
|
22
|
+
) => Promise<import('stylelint').LinterResult>;
|
|
23
|
+
rules: {
|
|
24
|
+
[k: string]: import('stylelint').Rule<any, any>;
|
|
25
|
+
};
|
|
26
|
+
formatters: {
|
|
27
|
+
[k: string]: import('stylelint').Formatter;
|
|
28
|
+
};
|
|
29
|
+
createPlugin: (
|
|
30
|
+
ruleName: string,
|
|
31
|
+
plugin: import('stylelint').Plugin<any, any>
|
|
32
|
+
) => {
|
|
33
|
+
ruleName: string;
|
|
34
|
+
rule: import('stylelint').Rule<any, any>;
|
|
35
|
+
};
|
|
36
|
+
createLinter: (
|
|
37
|
+
options: import('stylelint').LinterOptions
|
|
38
|
+
) => import('stylelint').InternalApi;
|
|
39
|
+
utils: {
|
|
40
|
+
report: (problem: import('stylelint').Problem) => void;
|
|
41
|
+
ruleMessages: <
|
|
42
|
+
T extends import('stylelint').RuleMessages,
|
|
43
|
+
R extends { [K in keyof T]: T[K] }
|
|
44
|
+
>(
|
|
45
|
+
ruleName: string,
|
|
46
|
+
messages: T
|
|
47
|
+
) => R;
|
|
48
|
+
validateOptions: (
|
|
49
|
+
result: import('stylelint').PostcssResult,
|
|
50
|
+
ruleName: string,
|
|
51
|
+
...optionDescriptions: import('stylelint').RuleOptions[]
|
|
52
|
+
) => boolean;
|
|
53
|
+
checkAgainstRule: <T_1, O extends Object>(
|
|
54
|
+
options: {
|
|
55
|
+
ruleName: string;
|
|
56
|
+
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
57
|
+
root: import('stylelint/node_modules/postcss').Root;
|
|
58
|
+
},
|
|
59
|
+
callback: (
|
|
60
|
+
warning: import('stylelint/node_modules/postcss').Warning
|
|
61
|
+
) => void
|
|
62
|
+
) => void;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
17
65
|
export type LintResult = import('stylelint').LintResult;
|
|
18
66
|
export type Compiler = import('webpack').Compiler;
|
|
19
67
|
export type Compilation = import('webpack').Compilation;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="stylelint" />
|
|
1
2
|
/** @typedef {import("stylelint")} stylelint */
|
|
2
3
|
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
|
|
3
4
|
/** @typedef {import("stylelint").FormatterType} FormatterType */
|
|
@@ -36,7 +37,54 @@ export function getOptions(pluginOptions: Options): Partial<PluginOptions>;
|
|
|
36
37
|
export function getStylelintOptions(
|
|
37
38
|
pluginOptions: Options
|
|
38
39
|
): Partial<StylelintOptions>;
|
|
39
|
-
export type stylelint =
|
|
40
|
+
export type stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
41
|
+
import('stylelint').PostcssPluginOptions
|
|
42
|
+
> & {
|
|
43
|
+
lint: (
|
|
44
|
+
options: import('stylelint').LinterOptions
|
|
45
|
+
) => Promise<import('stylelint').LinterResult>;
|
|
46
|
+
rules: {
|
|
47
|
+
[k: string]: import('stylelint').Rule<any, any>;
|
|
48
|
+
};
|
|
49
|
+
formatters: {
|
|
50
|
+
[k: string]: import('stylelint').Formatter;
|
|
51
|
+
};
|
|
52
|
+
createPlugin: (
|
|
53
|
+
ruleName: string,
|
|
54
|
+
plugin: import('stylelint').Plugin<any, any>
|
|
55
|
+
) => {
|
|
56
|
+
ruleName: string;
|
|
57
|
+
rule: import('stylelint').Rule<any, any>;
|
|
58
|
+
};
|
|
59
|
+
createLinter: (
|
|
60
|
+
options: import('stylelint').LinterOptions
|
|
61
|
+
) => import('stylelint').InternalApi;
|
|
62
|
+
utils: {
|
|
63
|
+
report: (problem: import('stylelint').Problem) => void;
|
|
64
|
+
ruleMessages: <
|
|
65
|
+
T extends import('stylelint').RuleMessages,
|
|
66
|
+
R extends { [K in keyof T]: T[K] }
|
|
67
|
+
>(
|
|
68
|
+
ruleName: string,
|
|
69
|
+
messages: T
|
|
70
|
+
) => R;
|
|
71
|
+
validateOptions: (
|
|
72
|
+
result: import('stylelint').PostcssResult,
|
|
73
|
+
ruleName: string,
|
|
74
|
+
...optionDescriptions: import('stylelint').RuleOptions[]
|
|
75
|
+
) => boolean;
|
|
76
|
+
checkAgainstRule: <T_1, O extends Object>(
|
|
77
|
+
options: {
|
|
78
|
+
ruleName: string;
|
|
79
|
+
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
80
|
+
root: import('stylelint/node_modules/postcss').Root;
|
|
81
|
+
},
|
|
82
|
+
callback: (
|
|
83
|
+
warning: import('stylelint/node_modules/postcss').Warning
|
|
84
|
+
) => void
|
|
85
|
+
) => void;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
40
88
|
export type StylelintOptions = import('stylelint').LinterOptions;
|
|
41
89
|
export type FormatterType = import('stylelint').FormatterType;
|
|
42
90
|
export type OutputReport = {
|
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/declarations/worker.d.ts
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="stylelint" />
|
|
2
|
+
export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
3
|
+
import('stylelint').PostcssPluginOptions
|
|
4
|
+
> & {
|
|
5
|
+
lint: (
|
|
6
|
+
options: import('stylelint').LinterOptions
|
|
7
|
+
) => Promise<import('stylelint').LinterResult>;
|
|
8
|
+
rules: {
|
|
9
|
+
[k: string]: import('stylelint').Rule<any, any>;
|
|
10
|
+
};
|
|
11
|
+
formatters: {
|
|
12
|
+
[k: string]: import('stylelint').Formatter;
|
|
13
|
+
};
|
|
14
|
+
createPlugin: (
|
|
15
|
+
ruleName: string,
|
|
16
|
+
plugin: import('stylelint').Plugin<any, any>
|
|
17
|
+
) => {
|
|
18
|
+
ruleName: string;
|
|
19
|
+
rule: import('stylelint').Rule<any, any>;
|
|
20
|
+
};
|
|
21
|
+
createLinter: (
|
|
22
|
+
options: import('stylelint').LinterOptions
|
|
23
|
+
) => import('stylelint').InternalApi;
|
|
24
|
+
utils: {
|
|
25
|
+
report: (problem: import('stylelint').Problem) => void;
|
|
26
|
+
ruleMessages: <
|
|
27
|
+
T extends import('stylelint').RuleMessages,
|
|
28
|
+
R extends { [K in keyof T]: T[K] }
|
|
29
|
+
>(
|
|
30
|
+
ruleName: string,
|
|
31
|
+
messages: T
|
|
32
|
+
) => R;
|
|
33
|
+
validateOptions: (
|
|
34
|
+
result: import('stylelint').PostcssResult,
|
|
35
|
+
ruleName: string,
|
|
36
|
+
...optionDescriptions: import('stylelint').RuleOptions[]
|
|
37
|
+
) => boolean;
|
|
38
|
+
checkAgainstRule: <T_1, O extends Object>(
|
|
39
|
+
options: {
|
|
40
|
+
ruleName: string;
|
|
41
|
+
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
42
|
+
root: import('stylelint/node_modules/postcss').Root;
|
|
43
|
+
},
|
|
44
|
+
callback: (
|
|
45
|
+
warning: import('stylelint/node_modules/postcss').Warning
|
|
46
|
+
) => void
|
|
47
|
+
) => void;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
2
50
|
export type StylelintOptions = import('stylelint').LinterOptions;
|
|
3
51
|
export type Options = import('./options').Options;
|
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
|
|
|
@@ -43,6 +43,8 @@ class StylelintWebpackPlugin {
|
|
|
43
43
|
this.options = (0, _options.getOptions)(options);
|
|
44
44
|
this.run = this.run.bind(this);
|
|
45
45
|
this.startTime = Date.now();
|
|
46
|
+
/** @type {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} */
|
|
47
|
+
|
|
46
48
|
this.prevTimestamps = new Map();
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
@@ -89,12 +91,12 @@ class StylelintWebpackPlugin {
|
|
|
89
91
|
|
|
90
92
|
const context = this.getContext(compiler);
|
|
91
93
|
const options = { ...this.options,
|
|
92
|
-
exclude: (0, _utils.parseFiles)(this.options.exclude || [], context),
|
|
94
|
+
exclude: (0, _utils.parseFiles)(this.options.exclude || ['**/node_modules/**', compiler.options.output.path], context),
|
|
93
95
|
extensions: (0, _arrify.default)(this.options.extensions),
|
|
94
96
|
files: (0, _utils.parseFiles)(this.options.files || '', context)
|
|
95
97
|
};
|
|
96
98
|
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions);
|
|
97
|
-
const exclude = (0, _utils.parseFoldersToGlobs)(
|
|
99
|
+
const exclude = (0, _utils.parseFoldersToGlobs)(options.exclude);
|
|
98
100
|
compiler.hooks.thisCompilation.tap(this.key, compilation => {
|
|
99
101
|
/** @type {import('./linter').Linter} */
|
|
100
102
|
let lint;
|
|
@@ -115,29 +117,15 @@ class StylelintWebpackPlugin {
|
|
|
115
117
|
compilation.errors.push(e);
|
|
116
118
|
return;
|
|
117
119
|
}
|
|
118
|
-
/** @type {string[]} */
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const files = []; // Add the file to be linted
|
|
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
120
|
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
compilation.hooks.finishModules.tap(this.key, () => {
|
|
122
|
+
const files = this.getFiles(compiler, wanted, exclude);
|
|
132
123
|
|
|
133
|
-
|
|
124
|
+
if (threads > 1) {
|
|
125
|
+
for (const file of files) {
|
|
134
126
|
lint((0, _utils.parseFiles)(file, context));
|
|
135
127
|
}
|
|
136
|
-
}
|
|
137
|
-
}); // Lint all files added
|
|
138
|
-
|
|
139
|
-
compilation.hooks.finishModules.tap(this.key, () => {
|
|
140
|
-
if (files.length > 0 && threads <= 1) {
|
|
128
|
+
} else if (files.length > 0) {
|
|
141
129
|
lint((0, _utils.parseFiles)(files, context));
|
|
142
130
|
}
|
|
143
131
|
}); // await and interpret results
|
|
@@ -192,63 +180,42 @@ class StylelintWebpackPlugin {
|
|
|
192
180
|
return this.options.context;
|
|
193
181
|
}
|
|
194
182
|
/**
|
|
195
|
-
* @param {string[]} glob
|
|
196
183
|
* @param {Compiler} compiler
|
|
197
|
-
* @param {
|
|
184
|
+
* @param {string[]} wanted
|
|
185
|
+
* @param {string[]} exclude
|
|
198
186
|
* @returns {string[]}
|
|
199
187
|
*/
|
|
200
188
|
// eslint-disable-next-line no-unused-vars
|
|
201
189
|
|
|
202
190
|
|
|
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
|
-
*/
|
|
191
|
+
getFiles(compiler, wanted, exclude) {
|
|
234
192
|
// webpack 5
|
|
235
193
|
if (compiler.modifiedFiles) {
|
|
236
|
-
return Array.from(compiler.modifiedFiles)
|
|
194
|
+
return Array.from(compiler.modifiedFiles).filter(file => (0, _micromatch.isMatch)(file, wanted, {
|
|
195
|
+
dot: true
|
|
196
|
+
}) && !(0, _micromatch.isMatch)(file, exclude, {
|
|
197
|
+
dot: true
|
|
198
|
+
}));
|
|
237
199
|
} // webpack 4
|
|
238
200
|
|
|
239
201
|
/* istanbul ignore next */
|
|
240
202
|
|
|
241
203
|
|
|
242
204
|
if (compiler.fileTimestamps && compiler.fileTimestamps.size > 0) {
|
|
243
|
-
return this.getChangedFiles(compiler.fileTimestamps)
|
|
205
|
+
return this.getChangedFiles(compiler.fileTimestamps).filter(file => (0, _micromatch.isMatch)(file, wanted, {
|
|
206
|
+
dot: true
|
|
207
|
+
}) && !(0, _micromatch.isMatch)(file, exclude, {
|
|
208
|
+
dot: true
|
|
209
|
+
}));
|
|
244
210
|
}
|
|
245
211
|
|
|
246
|
-
return
|
|
247
|
-
dot: true
|
|
212
|
+
return _globby.default.sync(wanted, {
|
|
213
|
+
dot: true,
|
|
214
|
+
ignore: exclude
|
|
248
215
|
});
|
|
249
216
|
}
|
|
250
217
|
/**
|
|
251
|
-
* @param {
|
|
218
|
+
* @param {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} fileTimestamps
|
|
252
219
|
* @returns {string[]}
|
|
253
220
|
*/
|
|
254
221
|
|
|
@@ -257,7 +224,7 @@ class StylelintWebpackPlugin {
|
|
|
257
224
|
|
|
258
225
|
getChangedFiles(fileTimestamps) {
|
|
259
226
|
/**
|
|
260
|
-
* @param {null | FileSystemInfoEntry | "ignore"} fileSystemInfoEntry
|
|
227
|
+
* @param {null | FileSystemInfoEntry | "ignore" | undefined} fileSystemInfoEntry
|
|
261
228
|
* @returns {Partial<number>}
|
|
262
229
|
*/
|
|
263
230
|
const getTimestamps = fileSystemInfoEntry => {
|
|
@@ -272,7 +239,7 @@ class StylelintWebpackPlugin {
|
|
|
272
239
|
};
|
|
273
240
|
/**
|
|
274
241
|
* @param {string} filename
|
|
275
|
-
* @param {null | FileSystemInfoEntry | "ignore"} fileSystemInfoEntry
|
|
242
|
+
* @param {null | FileSystemInfoEntry | "ignore" | undefined} fileSystemInfoEntry
|
|
276
243
|
* @returns {boolean}
|
|
277
244
|
*/
|
|
278
245
|
|
package/dist/linter.js
CHANGED
|
@@ -105,7 +105,7 @@ function linter(key, options, compilation) {
|
|
|
105
105
|
await cleanup();
|
|
106
106
|
|
|
107
107
|
for (const result of results) {
|
|
108
|
-
crossRunResultStorage[result.source] = result;
|
|
108
|
+
crossRunResultStorage[String(result.source)] = result;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
results = Object.values(crossRunResultStorage); // do not analyze if there are no results or stylelint config
|
|
@@ -215,24 +215,20 @@ function parseResults(options, results) {
|
|
|
215
215
|
|
|
216
216
|
const warnings = [];
|
|
217
217
|
results.forEach(file => {
|
|
218
|
-
|
|
219
|
-
const messages = file.warnings.filter(message => options.emitError && message.severity === 'error');
|
|
218
|
+
const fileErrors = file.warnings.filter(message => options.emitError && message.severity === 'error');
|
|
220
219
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
220
|
+
if (fileErrors.length > 0) {
|
|
221
|
+
errors.push({ ...file,
|
|
222
|
+
warnings: fileErrors
|
|
223
|
+
});
|
|
226
224
|
}
|
|
227
225
|
|
|
228
|
-
|
|
229
|
-
const messages = file.warnings.filter(message => options.emitWarning && message.severity === 'warning');
|
|
226
|
+
const fileWarnings = file.warnings.filter(message => options.emitWarning && message.severity === 'warning');
|
|
230
227
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
228
|
+
if (fileWarnings.length > 0) {
|
|
229
|
+
warnings.push({ ...file,
|
|
230
|
+
warnings: fileWarnings
|
|
231
|
+
});
|
|
236
232
|
}
|
|
237
233
|
});
|
|
238
234
|
return {
|
|
@@ -240,24 +236,6 @@ function parseResults(options, results) {
|
|
|
240
236
|
warnings
|
|
241
237
|
};
|
|
242
238
|
}
|
|
243
|
-
/**
|
|
244
|
-
* @param {LintResult} file
|
|
245
|
-
* @returns {boolean}
|
|
246
|
-
*/
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
function fileHasErrors(file) {
|
|
250
|
-
return !!file.errored;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* @param {LintResult} file
|
|
254
|
-
* @returns {boolean}
|
|
255
|
-
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
function fileHasWarnings(file) {
|
|
259
|
-
return file.warnings && file.warnings.length > 0;
|
|
260
|
-
}
|
|
261
239
|
/**
|
|
262
240
|
* @param {Stylelint} stylelint
|
|
263
241
|
* @param {FormatterType=} formatter
|
package/dist/utils.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.jsonStringifyReplacerSortKeys = void 0;
|
|
6
7
|
exports.parseFiles = parseFiles;
|
|
7
8
|
exports.parseFoldersToGlobs = parseFoldersToGlobs;
|
|
8
|
-
exports.jsonStringifyReplacerSortKeys = void 0;
|
|
9
9
|
|
|
10
10
|
var _path = require("path");
|
|
11
11
|
|
|
@@ -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.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "A Stylelint plugin for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/stylelint-webpack-plugin",
|
|
@@ -42,49 +42,50 @@
|
|
|
42
42
|
"declarations"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"stylelint": "^13.0.0",
|
|
45
|
+
"stylelint": "^13.0.0 || ^14.0.0",
|
|
46
46
|
"webpack": "^4.0.0 || ^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@types/stylelint": "^13.13.
|
|
49
|
+
"@types/stylelint": "^13.13.3",
|
|
50
50
|
"arrify": "^2.0.1",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
51
|
+
"jest-worker": "^27.3.1",
|
|
52
|
+
"globby": "^11.0.4",
|
|
53
53
|
"micromatch": "^4.0.4",
|
|
54
54
|
"normalize-path": "^3.0.0",
|
|
55
|
-
"schema-utils": "^3.
|
|
55
|
+
"schema-utils": "^3.1.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
58
|
+
"@babel/cli": "^7.16.0",
|
|
59
|
+
"@babel/core": "^7.16.0",
|
|
60
|
+
"@babel/preset-env": "^7.16.0",
|
|
61
61
|
"@commitlint/cli": "^12.1.4",
|
|
62
62
|
"@commitlint/config-conventional": "^12.1.4",
|
|
63
|
-
"@types/fs-extra": "^9.0.
|
|
64
|
-
"@types/micromatch": "^4.0.
|
|
63
|
+
"@types/fs-extra": "^9.0.13",
|
|
64
|
+
"@types/micromatch": "^4.0.2",
|
|
65
65
|
"@types/normalize-path": "^3.0.0",
|
|
66
66
|
"@types/webpack": "^5.28.0",
|
|
67
67
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
68
68
|
"babel-eslint": "^10.1.0",
|
|
69
|
-
"babel-jest": "^27.
|
|
69
|
+
"babel-jest": "^27.3.1",
|
|
70
70
|
"chokidar": "^3.5.2",
|
|
71
71
|
"cross-env": "^7.0.3",
|
|
72
72
|
"del": "^6.0.0",
|
|
73
73
|
"del-cli": "^3.0.1",
|
|
74
|
-
"eslint": "^7.
|
|
74
|
+
"eslint": "^7.32.0",
|
|
75
75
|
"eslint-config-prettier": "^8.3.0",
|
|
76
|
-
"eslint-plugin-import": "^2.
|
|
76
|
+
"eslint-plugin-import": "^2.25.2",
|
|
77
77
|
"file-loader": "^6.2.0",
|
|
78
78
|
"fs-extra": "^9.1.0",
|
|
79
79
|
"husky": "^6.0.0",
|
|
80
|
-
"jest": "^27.
|
|
80
|
+
"jest": "^27.3.1",
|
|
81
81
|
"lint-staged": "^10.5.4",
|
|
82
82
|
"npm-run-all": "^4.1.5",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
83
|
+
"postcss-scss": "^3.0.5",
|
|
84
|
+
"prettier": "^2.4.1",
|
|
85
|
+
"standard-version": "^9.3.2",
|
|
86
|
+
"stylelint": "^14.0.1",
|
|
87
|
+
"typescript": "^4.4.4",
|
|
88
|
+
"webpack": "^5.62.1"
|
|
88
89
|
},
|
|
89
90
|
"keywords": [
|
|
90
91
|
"stylelint",
|