stylelint-webpack-plugin 2.2.1 → 3.1.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/README.md +9 -9
- package/declarations/getStylelint.d.ts +47 -1
- package/declarations/index.d.ts +0 -14
- package/declarations/linter.d.ts +47 -1
- package/declarations/options.d.ts +47 -1
- package/declarations/utils.d.ts +28 -5
- package/declarations/worker.d.ts +47 -1
- package/dist/index.js +11 -88
- package/dist/linter.js +14 -38
- package/dist/utils.js +51 -10
- package/package.json +28 -28
package/README.md
CHANGED
|
@@ -13,23 +13,23 @@
|
|
|
13
13
|
|
|
14
14
|
# stylelint-webpack-plugin
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
This plugin uses [`stylelint`](https://stylelint.io/) that helps you avoid errors and enforce conventions in your styles.
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Getting Started
|
|
19
|
+
|
|
20
|
+
To begin, you'll need to install `stylelint-webpack-plugin`:
|
|
19
21
|
|
|
20
22
|
```bash
|
|
21
23
|
npm install stylelint-webpack-plugin --save-dev
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
**Note**: You also need to install `stylelint` from npm, if you haven't already:
|
|
26
|
+
**Note**: You also need to install `stylelint >= 13` from npm, if you haven't already:
|
|
25
27
|
|
|
26
28
|
```bash
|
|
27
29
|
npm install stylelint --save-dev
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
In your webpack configuration:
|
|
32
|
+
Then add the plugin to your webpack config. For example:
|
|
33
33
|
|
|
34
34
|
```js
|
|
35
35
|
const StylelintPlugin = require('stylelint-webpack-plugin');
|
|
@@ -125,21 +125,21 @@ You can still force this behavior by using `emitError` **or** `emitWarning` opti
|
|
|
125
125
|
#### `emitError`
|
|
126
126
|
|
|
127
127
|
- Type: `Boolean`
|
|
128
|
-
- Default: `
|
|
128
|
+
- Default: `true`
|
|
129
129
|
|
|
130
130
|
The errors found will always be emitted, to disable set to `false`.
|
|
131
131
|
|
|
132
132
|
#### `emitWarning`
|
|
133
133
|
|
|
134
134
|
- Type: `Boolean`
|
|
135
|
-
- Default: `
|
|
135
|
+
- Default: `true`
|
|
136
136
|
|
|
137
137
|
The warnings found will always be emitted, to disable set to `false`.
|
|
138
138
|
|
|
139
139
|
#### `failOnError`
|
|
140
140
|
|
|
141
141
|
- Type: `Boolean`
|
|
142
|
-
- Default: `
|
|
142
|
+
- Default: `true`
|
|
143
143
|
|
|
144
144
|
Will cause the module build to fail if there are any errors, to disable set to `false`.
|
|
145
145
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="stylelint" />
|
|
1
2
|
/**
|
|
2
3
|
* @param {string|undefined} key
|
|
3
4
|
* @param {Options} options
|
|
@@ -7,7 +8,52 @@ 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('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('postcss').Root;
|
|
52
|
+
},
|
|
53
|
+
callback: (warning: import('postcss').Warning) => void
|
|
54
|
+
) => void;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
11
57
|
export type LintResult = import('stylelint').LintResult;
|
|
12
58
|
export type Options = import('./options').Options;
|
|
13
59
|
export type AsyncTask = () => Promise<void>;
|
package/declarations/index.d.ts
CHANGED
|
@@ -32,18 +32,4 @@ declare class StylelintWebpackPlugin {
|
|
|
32
32
|
* @returns {string}
|
|
33
33
|
*/
|
|
34
34
|
getContext(compiler: Compiler): string;
|
|
35
|
-
/**
|
|
36
|
-
* @param {Compiler} compiler
|
|
37
|
-
* @param {string[]} wanted
|
|
38
|
-
* @param {string[]} exclude
|
|
39
|
-
* @returns {string[]}
|
|
40
|
-
*/
|
|
41
|
-
getFiles(compiler: Compiler, wanted: string[], exclude: string[]): string[];
|
|
42
|
-
/**
|
|
43
|
-
* @param {Map<string, null | FileSystemInfoEntry | "ignore">} fileTimestamps
|
|
44
|
-
* @returns {string[]}
|
|
45
|
-
*/
|
|
46
|
-
getChangedFiles(
|
|
47
|
-
fileTimestamps: Map<string, 'ignore' | FileSystemInfoEntry | null>
|
|
48
|
-
): string[];
|
|
49
35
|
}
|
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,52 @@ export default function linter(
|
|
|
13
14
|
report: Reporter;
|
|
14
15
|
threads: number;
|
|
15
16
|
};
|
|
16
|
-
export type Stylelint =
|
|
17
|
+
export type Stylelint = import('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('postcss').Root;
|
|
58
|
+
},
|
|
59
|
+
callback: (warning: import('postcss').Warning) => void
|
|
60
|
+
) => void;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
17
63
|
export type LintResult = import('stylelint').LintResult;
|
|
18
64
|
export type Compiler = import('webpack').Compiler;
|
|
19
65
|
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,52 @@ 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('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('postcss').Root;
|
|
81
|
+
},
|
|
82
|
+
callback: (warning: import('postcss').Warning) => void
|
|
83
|
+
) => void;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
40
86
|
export type StylelintOptions = import('stylelint').LinterOptions;
|
|
41
87
|
export type FormatterType = import('stylelint').FormatterType;
|
|
42
88
|
export type OutputReport = {
|
package/declarations/utils.d.ts
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T} value
|
|
4
|
+
* @return {
|
|
5
|
+
T extends (null | undefined)
|
|
6
|
+
? []
|
|
7
|
+
: T extends string
|
|
8
|
+
? [string]
|
|
9
|
+
: T extends readonly unknown[]
|
|
10
|
+
? T
|
|
11
|
+
: T extends Iterable<infer T>
|
|
12
|
+
? T[]
|
|
13
|
+
: [T]
|
|
14
|
+
}
|
|
15
|
+
*/
|
|
16
|
+
export function arrify<T>(
|
|
17
|
+
value: T
|
|
18
|
+
): T extends null | undefined
|
|
19
|
+
? []
|
|
20
|
+
: T extends string
|
|
21
|
+
? [string]
|
|
22
|
+
: T extends readonly unknown[]
|
|
23
|
+
? T
|
|
24
|
+
: T extends Iterable<infer T_1>
|
|
25
|
+
? T_1[]
|
|
26
|
+
: [T];
|
|
27
|
+
/**
|
|
28
|
+
* @param {string|string[]} files
|
|
3
29
|
* @param {string} context
|
|
4
30
|
* @returns {string[]}
|
|
5
31
|
*/
|
|
6
|
-
export function parseFiles(
|
|
7
|
-
files: string | (string | undefined)[],
|
|
8
|
-
context: string
|
|
9
|
-
): string[];
|
|
32
|
+
export function parseFiles(files: string | string[], context: string): string[];
|
|
10
33
|
/**
|
|
11
34
|
* @param {string|string[]} patterns
|
|
12
35
|
* @param {string|string[]} extensions
|
package/declarations/worker.d.ts
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="stylelint" />
|
|
2
|
+
export type Stylelint = import('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('postcss').Root;
|
|
43
|
+
},
|
|
44
|
+
callback: (warning: import('postcss').Warning) => void
|
|
45
|
+
) => void;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
2
48
|
export type StylelintOptions = import('stylelint').LinterOptions;
|
|
3
49
|
export type Options = import('./options').Options;
|
package/dist/index.js
CHANGED
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _path = require("path");
|
|
9
9
|
|
|
10
|
-
var _arrify = _interopRequireDefault(require("arrify"));
|
|
11
|
-
|
|
12
10
|
var _globby = _interopRequireDefault(require("globby"));
|
|
13
11
|
|
|
14
12
|
var _micromatch = require("micromatch");
|
|
@@ -21,7 +19,6 @@ var _utils = require("./utils");
|
|
|
21
19
|
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
21
|
|
|
24
|
-
// @ts-ignore
|
|
25
22
|
// @ts-ignore
|
|
26
23
|
|
|
27
24
|
/** @typedef {import('webpack').Compiler} Compiler */
|
|
@@ -88,9 +85,10 @@ class StylelintWebpackPlugin {
|
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
const context = this.getContext(compiler);
|
|
88
|
+
const excludeDefault = ['**/node_modules/**', String(compiler.options.output.path)];
|
|
91
89
|
const options = { ...this.options,
|
|
92
|
-
exclude: (0, _utils.parseFiles)(this.options.exclude ||
|
|
93
|
-
extensions: (0,
|
|
90
|
+
exclude: (0, _utils.parseFiles)(this.options.exclude || excludeDefault, context),
|
|
91
|
+
extensions: (0, _utils.arrify)(this.options.extensions),
|
|
94
92
|
files: (0, _utils.parseFiles)(this.options.files || '', context)
|
|
95
93
|
};
|
|
96
94
|
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions);
|
|
@@ -117,7 +115,14 @@ class StylelintWebpackPlugin {
|
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
compilation.hooks.finishModules.tap(this.key, () => {
|
|
120
|
-
const files =
|
|
118
|
+
const files = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles).filter(file => (0, _micromatch.isMatch)(file, wanted, {
|
|
119
|
+
dot: true
|
|
120
|
+
}) && !(0, _micromatch.isMatch)(file, exclude, {
|
|
121
|
+
dot: true
|
|
122
|
+
})) : _globby.default.sync(wanted, {
|
|
123
|
+
dot: true,
|
|
124
|
+
ignore: exclude
|
|
125
|
+
});
|
|
121
126
|
|
|
122
127
|
if (threads > 1) {
|
|
123
128
|
for (const file of files) {
|
|
@@ -177,88 +182,6 @@ class StylelintWebpackPlugin {
|
|
|
177
182
|
|
|
178
183
|
return this.options.context;
|
|
179
184
|
}
|
|
180
|
-
/**
|
|
181
|
-
* @param {Compiler} compiler
|
|
182
|
-
* @param {string[]} wanted
|
|
183
|
-
* @param {string[]} exclude
|
|
184
|
-
* @returns {string[]}
|
|
185
|
-
*/
|
|
186
|
-
// eslint-disable-next-line no-unused-vars
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
getFiles(compiler, wanted, exclude) {
|
|
190
|
-
// webpack 5
|
|
191
|
-
if (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
|
-
}));
|
|
197
|
-
} // webpack 4
|
|
198
|
-
|
|
199
|
-
/* istanbul ignore next */
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (compiler.fileTimestamps && compiler.fileTimestamps.size > 0) {
|
|
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
|
-
}));
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return _globby.default.sync(wanted, {
|
|
211
|
-
dot: true,
|
|
212
|
-
ignore: exclude
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* @param {Map<string, null | FileSystemInfoEntry | "ignore">} fileTimestamps
|
|
217
|
-
* @returns {string[]}
|
|
218
|
-
*/
|
|
219
|
-
|
|
220
|
-
/* istanbul ignore next */
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
getChangedFiles(fileTimestamps) {
|
|
224
|
-
/**
|
|
225
|
-
* @param {null | FileSystemInfoEntry | "ignore"} fileSystemInfoEntry
|
|
226
|
-
* @returns {Partial<number>}
|
|
227
|
-
*/
|
|
228
|
-
const getTimestamps = fileSystemInfoEntry => {
|
|
229
|
-
// @ts-ignore
|
|
230
|
-
if (fileSystemInfoEntry && fileSystemInfoEntry.timestamp) {
|
|
231
|
-
// @ts-ignore
|
|
232
|
-
return fileSystemInfoEntry.timestamp;
|
|
233
|
-
} // @ts-ignore
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return fileSystemInfoEntry;
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* @param {string} filename
|
|
240
|
-
* @param {null | FileSystemInfoEntry | "ignore"} fileSystemInfoEntry
|
|
241
|
-
* @returns {boolean}
|
|
242
|
-
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const hasFileChanged = (filename, fileSystemInfoEntry) => {
|
|
246
|
-
const prevTimestamp = getTimestamps(this.prevTimestamps.get(filename));
|
|
247
|
-
const timestamp = getTimestamps(fileSystemInfoEntry);
|
|
248
|
-
return (prevTimestamp || this.startTime) < (timestamp || Infinity);
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const changedFiles = [];
|
|
252
|
-
|
|
253
|
-
for (const [filename, timestamp] of fileTimestamps.entries()) {
|
|
254
|
-
if (hasFileChanged(filename, timestamp)) {
|
|
255
|
-
changedFiles.push(filename);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
this.prevTimestamps = fileTimestamps;
|
|
260
|
-
return changedFiles;
|
|
261
|
-
}
|
|
262
185
|
|
|
263
186
|
}
|
|
264
187
|
|
package/dist/linter.js
CHANGED
|
@@ -7,15 +7,13 @@ exports.default = linter;
|
|
|
7
7
|
|
|
8
8
|
var _path = require("path");
|
|
9
9
|
|
|
10
|
-
var _arrify = _interopRequireDefault(require("arrify"));
|
|
11
|
-
|
|
12
10
|
var _StylelintError = _interopRequireDefault(require("./StylelintError"));
|
|
13
11
|
|
|
14
12
|
var _getStylelint = _interopRequireDefault(require("./getStylelint"));
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
var _utils = require("./utils");
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
17
|
|
|
20
18
|
/** @typedef {import('stylelint')} Stylelint */
|
|
21
19
|
|
|
@@ -88,7 +86,7 @@ function linter(key, options, compilation) {
|
|
|
88
86
|
*/
|
|
89
87
|
|
|
90
88
|
function lint(files) {
|
|
91
|
-
for (const file of (0,
|
|
89
|
+
for (const file of (0, _utils.arrify)(files)) {
|
|
92
90
|
delete crossRunResultStorage[file];
|
|
93
91
|
}
|
|
94
92
|
|
|
@@ -105,7 +103,7 @@ function linter(key, options, compilation) {
|
|
|
105
103
|
await cleanup();
|
|
106
104
|
|
|
107
105
|
for (const result of results) {
|
|
108
|
-
crossRunResultStorage[result.source] = result;
|
|
106
|
+
crossRunResultStorage[String(result.source)] = result;
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
results = Object.values(crossRunResultStorage); // do not analyze if there are no results or stylelint config
|
|
@@ -215,24 +213,20 @@ function parseResults(options, results) {
|
|
|
215
213
|
|
|
216
214
|
const warnings = [];
|
|
217
215
|
results.forEach(file => {
|
|
218
|
-
|
|
219
|
-
const messages = file.warnings.filter(message => options.emitError && message.severity === 'error');
|
|
216
|
+
const fileErrors = file.warnings.filter(message => options.emitError && message.severity === 'error');
|
|
220
217
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
218
|
+
if (fileErrors.length > 0) {
|
|
219
|
+
errors.push({ ...file,
|
|
220
|
+
warnings: fileErrors
|
|
221
|
+
});
|
|
226
222
|
}
|
|
227
223
|
|
|
228
|
-
|
|
229
|
-
const messages = file.warnings.filter(message => options.emitWarning && message.severity === 'warning');
|
|
224
|
+
const fileWarnings = file.warnings.filter(message => options.emitWarning && message.severity === 'warning');
|
|
230
225
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
226
|
+
if (fileWarnings.length > 0) {
|
|
227
|
+
warnings.push({ ...file,
|
|
228
|
+
warnings: fileWarnings
|
|
229
|
+
});
|
|
236
230
|
}
|
|
237
231
|
});
|
|
238
232
|
return {
|
|
@@ -240,24 +234,6 @@ function parseResults(options, results) {
|
|
|
240
234
|
warnings
|
|
241
235
|
};
|
|
242
236
|
}
|
|
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
237
|
/**
|
|
262
238
|
* @param {Stylelint} stylelint
|
|
263
239
|
* @param {FormatterType=} formatter
|
package/dist/utils.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.arrify = arrify;
|
|
7
|
+
exports.jsonStringifyReplacerSortKeys = void 0;
|
|
6
8
|
exports.parseFiles = parseFiles;
|
|
7
9
|
exports.parseFoldersToGlobs = parseFoldersToGlobs;
|
|
8
|
-
exports.jsonStringifyReplacerSortKeys = void 0;
|
|
9
10
|
|
|
10
11
|
var _path = require("path");
|
|
11
12
|
|
|
@@ -13,22 +14,62 @@ var _fs = require("fs");
|
|
|
13
14
|
|
|
14
15
|
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
|
15
16
|
|
|
16
|
-
var _arrify = _interopRequireDefault(require("arrify"));
|
|
17
|
-
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
18
|
|
|
20
|
-
// @ts-ignore
|
|
21
19
|
// @ts-ignore
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
|
-
* @
|
|
22
|
+
* @template T
|
|
23
|
+
* @param {T} value
|
|
24
|
+
* @return {
|
|
25
|
+
T extends (null | undefined)
|
|
26
|
+
? []
|
|
27
|
+
: T extends string
|
|
28
|
+
? [string]
|
|
29
|
+
: T extends readonly unknown[]
|
|
30
|
+
? T
|
|
31
|
+
: T extends Iterable<infer T>
|
|
32
|
+
? T[]
|
|
33
|
+
: [T]
|
|
34
|
+
}
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/* istanbul ignore next */
|
|
38
|
+
function arrify(value) {
|
|
39
|
+
// eslint-disable-next-line no-undefined
|
|
40
|
+
if (value === null || value === undefined) {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof value === 'string') {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
return [value];
|
|
53
|
+
} // @ts-ignore
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if (typeof value[Symbol.iterator] === 'function') {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
return [...value];
|
|
59
|
+
} // @ts-ignore
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return [value];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @param {string|string[]} files
|
|
25
66
|
* @param {string} context
|
|
26
67
|
* @returns {string[]}
|
|
27
68
|
*/
|
|
69
|
+
|
|
70
|
+
|
|
28
71
|
function parseFiles(files, context) {
|
|
29
|
-
return (
|
|
30
|
-
/** @type {string} */
|
|
31
|
-
file) => typeof file === 'string').map((
|
|
72
|
+
return arrify(files).map((
|
|
32
73
|
/** @type {string} */
|
|
33
74
|
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file)));
|
|
34
75
|
}
|
|
@@ -40,12 +81,12 @@ function parseFiles(files, context) {
|
|
|
40
81
|
|
|
41
82
|
|
|
42
83
|
function parseFoldersToGlobs(patterns, extensions = []) {
|
|
43
|
-
const extensionsList = (
|
|
84
|
+
const extensionsList = arrify(extensions);
|
|
44
85
|
const [prefix, postfix] = extensionsList.length > 1 ? ['{', '}'] : ['', ''];
|
|
45
86
|
const extensionsGlob = extensionsList.map((
|
|
46
87
|
/** @type {string} */
|
|
47
88
|
extension) => extension.replace(/^\./u, '')).join(',');
|
|
48
|
-
return (
|
|
89
|
+
return arrify(patterns).map((
|
|
49
90
|
/** @type {string} */
|
|
50
91
|
pattern) => {
|
|
51
92
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-webpack-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A Stylelint plugin for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/stylelint-webpack-plugin",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"main": "dist/cjs.js",
|
|
15
15
|
"types": "declarations/index.d.ts",
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">= 12.13.0"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"start": "npm run build -- -w",
|
|
@@ -42,49 +42,49 @@
|
|
|
42
42
|
"declarations"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"stylelint": "^13.0.0",
|
|
46
|
-
"webpack": "^
|
|
45
|
+
"stylelint": "^13.0.0 || ^14.0.0",
|
|
46
|
+
"webpack": "^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@types/stylelint": "^13.13.
|
|
50
|
-
"arrify": "^2.0.1",
|
|
51
|
-
"jest-worker": "^27.0.2",
|
|
49
|
+
"@types/stylelint": "^13.13.3",
|
|
52
50
|
"globby": "^11.0.4",
|
|
51
|
+
"jest-worker": "^27.3.1",
|
|
53
52
|
"micromatch": "^4.0.4",
|
|
54
53
|
"normalize-path": "^3.0.0",
|
|
55
|
-
"schema-utils": "^3.
|
|
54
|
+
"schema-utils": "^3.1.1"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
61
|
-
"@commitlint/cli": "^
|
|
62
|
-
"@commitlint/config-conventional": "^
|
|
63
|
-
"@types/fs-extra": "^9.0.
|
|
64
|
-
"@types/micromatch": "^4.0.
|
|
57
|
+
"@babel/cli": "^7.16.0",
|
|
58
|
+
"@babel/core": "^7.16.0",
|
|
59
|
+
"@babel/preset-env": "^7.16.0",
|
|
60
|
+
"@commitlint/cli": "^14.1.0",
|
|
61
|
+
"@commitlint/config-conventional": "^14.1.0",
|
|
62
|
+
"@types/fs-extra": "^9.0.13",
|
|
63
|
+
"@types/micromatch": "^4.0.2",
|
|
65
64
|
"@types/normalize-path": "^3.0.0",
|
|
66
65
|
"@types/webpack": "^5.28.0",
|
|
67
66
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
68
67
|
"babel-eslint": "^10.1.0",
|
|
69
|
-
"babel-jest": "^27.
|
|
68
|
+
"babel-jest": "^27.3.1",
|
|
70
69
|
"chokidar": "^3.5.2",
|
|
71
70
|
"cross-env": "^7.0.3",
|
|
72
71
|
"del": "^6.0.0",
|
|
73
|
-
"del-cli": "^
|
|
74
|
-
"eslint": "^
|
|
72
|
+
"del-cli": "^4.0.1",
|
|
73
|
+
"eslint": "^8.1.0",
|
|
75
74
|
"eslint-config-prettier": "^8.3.0",
|
|
76
|
-
"eslint-plugin-import": "^2.
|
|
75
|
+
"eslint-plugin-import": "^2.25.2",
|
|
77
76
|
"file-loader": "^6.2.0",
|
|
78
|
-
"fs-extra": "^
|
|
79
|
-
"husky": "^
|
|
80
|
-
"jest": "^27.
|
|
81
|
-
"lint-staged": "^
|
|
77
|
+
"fs-extra": "^10.0.0",
|
|
78
|
+
"husky": "^7.0.4",
|
|
79
|
+
"jest": "^27.3.1",
|
|
80
|
+
"lint-staged": "^11.2.6",
|
|
82
81
|
"npm-run-all": "^4.1.5",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
82
|
+
"postcss-scss": "^4.0.2",
|
|
83
|
+
"prettier": "^2.4.1",
|
|
84
|
+
"standard-version": "^9.3.2",
|
|
85
|
+
"stylelint": "^14.0.1",
|
|
86
|
+
"typescript": "^4.4.4",
|
|
87
|
+
"webpack": "^5.61.0"
|
|
88
88
|
},
|
|
89
89
|
"keywords": [
|
|
90
90
|
"stylelint",
|