stylelint-webpack-plugin 2.3.0 → 3.0.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 +6 -6
- package/declarations/getStylelint.d.ts +1 -49
- package/declarations/index.d.ts +1 -22
- package/declarations/linter.d.ts +1 -49
- package/declarations/options.d.ts +1 -49
- package/declarations/utils.d.ts +28 -5
- package/declarations/worker.d.ts +1 -49
- package/dist/index.js +11 -90
- package/dist/linter.js +4 -6
- package/dist/utils.js +49 -10
- package/package.json +24 -26
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');
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="stylelint" />
|
|
2
1
|
/**
|
|
3
2
|
* @param {string|undefined} key
|
|
4
3
|
* @param {Options} options
|
|
@@ -8,54 +7,7 @@ export default function getStylelint(
|
|
|
8
7
|
key: string | undefined,
|
|
9
8
|
{ threads, ...options }: Options
|
|
10
9
|
): Linter;
|
|
11
|
-
export type Stylelint = import('stylelint
|
|
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
|
-
};
|
|
10
|
+
export type Stylelint = typeof import('stylelint');
|
|
59
11
|
export type LintResult = import('stylelint').LintResult;
|
|
60
12
|
export type Options = import('./options').Options;
|
|
61
13
|
export type AsyncTask = () => Promise<void>;
|
package/declarations/index.d.ts
CHANGED
|
@@ -20,11 +20,7 @@ declare class StylelintWebpackPlugin {
|
|
|
20
20
|
*/
|
|
21
21
|
run(compiler: Compiler): Promise<void>;
|
|
22
22
|
startTime: number;
|
|
23
|
-
|
|
24
|
-
prevTimestamps: ReadonlyMap<
|
|
25
|
-
string,
|
|
26
|
-
'ignore' | FileSystemInfoEntry | null | undefined
|
|
27
|
-
>;
|
|
23
|
+
prevTimestamps: Map<any, any>;
|
|
28
24
|
/**
|
|
29
25
|
* @param {Compiler} compiler
|
|
30
26
|
* @returns {void}
|
|
@@ -36,21 +32,4 @@ declare class StylelintWebpackPlugin {
|
|
|
36
32
|
* @returns {string}
|
|
37
33
|
*/
|
|
38
34
|
getContext(compiler: Compiler): string;
|
|
39
|
-
/**
|
|
40
|
-
* @param {Compiler} compiler
|
|
41
|
-
* @param {string[]} wanted
|
|
42
|
-
* @param {string[]} exclude
|
|
43
|
-
* @returns {string[]}
|
|
44
|
-
*/
|
|
45
|
-
getFiles(compiler: Compiler, wanted: string[], exclude: string[]): string[];
|
|
46
|
-
/**
|
|
47
|
-
* @param {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} fileTimestamps
|
|
48
|
-
* @returns {string[]}
|
|
49
|
-
*/
|
|
50
|
-
getChangedFiles(
|
|
51
|
-
fileTimestamps: ReadonlyMap<
|
|
52
|
-
string,
|
|
53
|
-
'ignore' | FileSystemInfoEntry | null | undefined
|
|
54
|
-
>
|
|
55
|
-
): string[];
|
|
56
35
|
}
|
package/declarations/linter.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="stylelint" />
|
|
2
1
|
/**
|
|
3
2
|
* @param {string|undefined} key
|
|
4
3
|
* @param {Options} options
|
|
@@ -14,54 +13,7 @@ export default function linter(
|
|
|
14
13
|
report: Reporter;
|
|
15
14
|
threads: number;
|
|
16
15
|
};
|
|
17
|
-
export type Stylelint = import('stylelint
|
|
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
|
-
};
|
|
16
|
+
export type Stylelint = typeof import('stylelint');
|
|
65
17
|
export type LintResult = import('stylelint').LintResult;
|
|
66
18
|
export type Compiler = import('webpack').Compiler;
|
|
67
19
|
export type Compilation = import('webpack').Compilation;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="stylelint" />
|
|
2
1
|
/** @typedef {import("stylelint")} stylelint */
|
|
3
2
|
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
|
|
4
3
|
/** @typedef {import("stylelint").FormatterType} FormatterType */
|
|
@@ -37,54 +36,7 @@ export function getOptions(pluginOptions: Options): Partial<PluginOptions>;
|
|
|
37
36
|
export function getStylelintOptions(
|
|
38
37
|
pluginOptions: Options
|
|
39
38
|
): Partial<StylelintOptions>;
|
|
40
|
-
export type stylelint = import('stylelint
|
|
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
|
-
};
|
|
39
|
+
export type stylelint = typeof import('stylelint');
|
|
88
40
|
export type StylelintOptions = import('stylelint').LinterOptions;
|
|
89
41
|
export type FormatterType = import('stylelint').FormatterType;
|
|
90
42
|
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,51 +1,3 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
export type Stylelint = typeof import('stylelint');
|
|
50
2
|
export type StylelintOptions = import('stylelint').LinterOptions;
|
|
51
3
|
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 */
|
|
@@ -43,8 +40,6 @@ class StylelintWebpackPlugin {
|
|
|
43
40
|
this.options = (0, _options.getOptions)(options);
|
|
44
41
|
this.run = this.run.bind(this);
|
|
45
42
|
this.startTime = Date.now();
|
|
46
|
-
/** @type {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} */
|
|
47
|
-
|
|
48
43
|
this.prevTimestamps = new Map();
|
|
49
44
|
}
|
|
50
45
|
/**
|
|
@@ -90,9 +85,10 @@ class StylelintWebpackPlugin {
|
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
const context = this.getContext(compiler);
|
|
88
|
+
const excludeDefault = ['**/node_modules/**', String(compiler.options.output.path)];
|
|
93
89
|
const options = { ...this.options,
|
|
94
|
-
exclude: (0, _utils.parseFiles)(this.options.exclude ||
|
|
95
|
-
extensions: (0,
|
|
90
|
+
exclude: (0, _utils.parseFiles)(this.options.exclude || excludeDefault, context),
|
|
91
|
+
extensions: (0, _utils.arrify)(this.options.extensions),
|
|
96
92
|
files: (0, _utils.parseFiles)(this.options.files || '', context)
|
|
97
93
|
};
|
|
98
94
|
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions);
|
|
@@ -119,7 +115,14 @@ class StylelintWebpackPlugin {
|
|
|
119
115
|
}
|
|
120
116
|
|
|
121
117
|
compilation.hooks.finishModules.tap(this.key, () => {
|
|
122
|
-
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
|
+
});
|
|
123
126
|
|
|
124
127
|
if (threads > 1) {
|
|
125
128
|
for (const file of files) {
|
|
@@ -179,88 +182,6 @@ class StylelintWebpackPlugin {
|
|
|
179
182
|
|
|
180
183
|
return this.options.context;
|
|
181
184
|
}
|
|
182
|
-
/**
|
|
183
|
-
* @param {Compiler} compiler
|
|
184
|
-
* @param {string[]} wanted
|
|
185
|
-
* @param {string[]} exclude
|
|
186
|
-
* @returns {string[]}
|
|
187
|
-
*/
|
|
188
|
-
// eslint-disable-next-line no-unused-vars
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
getFiles(compiler, wanted, exclude) {
|
|
192
|
-
// webpack 5
|
|
193
|
-
if (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
|
-
}));
|
|
199
|
-
} // webpack 4
|
|
200
|
-
|
|
201
|
-
/* istanbul ignore next */
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (compiler.fileTimestamps && compiler.fileTimestamps.size > 0) {
|
|
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
|
-
}));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return _globby.default.sync(wanted, {
|
|
213
|
-
dot: true,
|
|
214
|
-
ignore: exclude
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* @param {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} fileTimestamps
|
|
219
|
-
* @returns {string[]}
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
/* istanbul ignore next */
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
getChangedFiles(fileTimestamps) {
|
|
226
|
-
/**
|
|
227
|
-
* @param {null | FileSystemInfoEntry | "ignore" | undefined} fileSystemInfoEntry
|
|
228
|
-
* @returns {Partial<number>}
|
|
229
|
-
*/
|
|
230
|
-
const getTimestamps = fileSystemInfoEntry => {
|
|
231
|
-
// @ts-ignore
|
|
232
|
-
if (fileSystemInfoEntry && fileSystemInfoEntry.timestamp) {
|
|
233
|
-
// @ts-ignore
|
|
234
|
-
return fileSystemInfoEntry.timestamp;
|
|
235
|
-
} // @ts-ignore
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return fileSystemInfoEntry;
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* @param {string} filename
|
|
242
|
-
* @param {null | FileSystemInfoEntry | "ignore" | undefined} fileSystemInfoEntry
|
|
243
|
-
* @returns {boolean}
|
|
244
|
-
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const hasFileChanged = (filename, fileSystemInfoEntry) => {
|
|
248
|
-
const prevTimestamp = getTimestamps(this.prevTimestamps.get(filename));
|
|
249
|
-
const timestamp = getTimestamps(fileSystemInfoEntry);
|
|
250
|
-
return (prevTimestamp || this.startTime) < (timestamp || Infinity);
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
const changedFiles = [];
|
|
254
|
-
|
|
255
|
-
for (const [filename, timestamp] of fileTimestamps.entries()) {
|
|
256
|
-
if (hasFileChanged(filename, timestamp)) {
|
|
257
|
-
changedFiles.push(filename);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
this.prevTimestamps = fileTimestamps;
|
|
262
|
-
return changedFiles;
|
|
263
|
-
}
|
|
264
185
|
|
|
265
186
|
}
|
|
266
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[
|
|
106
|
+
crossRunResultStorage[result.source] = result;
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
results = Object.values(crossRunResultStorage); // do not analyze if there are no results or stylelint config
|
package/dist/utils.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.arrify = arrify;
|
|
7
7
|
exports.parseFiles = parseFiles;
|
|
8
8
|
exports.parseFoldersToGlobs = parseFoldersToGlobs;
|
|
9
|
+
exports.jsonStringifyReplacerSortKeys = void 0;
|
|
9
10
|
|
|
10
11
|
var _path = require("path");
|
|
11
12
|
|
|
@@ -13,22 +14,60 @@ 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
19
|
// @ts-ignore
|
|
21
|
-
// @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
|
+
function arrify(value) {
|
|
37
|
+
// eslint-disable-next-line no-undefined
|
|
38
|
+
if (value === null || value === undefined) {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (Array.isArray(value)) {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof value === 'string') {
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
return [value];
|
|
51
|
+
} // @ts-ignore
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if (typeof value[Symbol.iterator] === 'function') {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
return [...value];
|
|
57
|
+
} // @ts-ignore
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
return [value];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @param {string|string[]} files
|
|
25
64
|
* @param {string} context
|
|
26
65
|
* @returns {string[]}
|
|
27
66
|
*/
|
|
67
|
+
|
|
68
|
+
|
|
28
69
|
function parseFiles(files, context) {
|
|
29
|
-
return (
|
|
30
|
-
/** @type {string} */
|
|
31
|
-
file) => typeof file === 'string').map((
|
|
70
|
+
return arrify(files).map((
|
|
32
71
|
/** @type {string} */
|
|
33
72
|
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file)));
|
|
34
73
|
}
|
|
@@ -40,12 +79,12 @@ function parseFiles(files, context) {
|
|
|
40
79
|
|
|
41
80
|
|
|
42
81
|
function parseFoldersToGlobs(patterns, extensions = []) {
|
|
43
|
-
const extensionsList = (
|
|
82
|
+
const extensionsList = arrify(extensions);
|
|
44
83
|
const [prefix, postfix] = extensionsList.length > 1 ? ['{', '}'] : ['', ''];
|
|
45
84
|
const extensionsGlob = extensionsList.map((
|
|
46
85
|
/** @type {string} */
|
|
47
86
|
extension) => extension.replace(/^\./u, '')).join(',');
|
|
48
|
-
return (
|
|
87
|
+
return arrify(patterns).map((
|
|
49
88
|
/** @type {string} */
|
|
50
89
|
pattern) => {
|
|
51
90
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-webpack-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
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,50 +42,48 @@
|
|
|
42
42
|
"declarations"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"stylelint": "^13.0.0
|
|
46
|
-
"webpack": "^
|
|
45
|
+
"stylelint": "^13.0.0",
|
|
46
|
+
"webpack": "^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@types/stylelint": "^13.13.
|
|
50
|
-
"
|
|
51
|
-
"jest-worker": "^27.3.1",
|
|
49
|
+
"@types/stylelint": "^13.13.1",
|
|
50
|
+
"jest-worker": "^27.0.6",
|
|
52
51
|
"globby": "^11.0.4",
|
|
53
52
|
"micromatch": "^4.0.4",
|
|
54
53
|
"normalize-path": "^3.0.0",
|
|
55
|
-
"schema-utils": "^3.1.
|
|
54
|
+
"schema-utils": "^3.1.0"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
57
|
+
"@babel/cli": "^7.14.5",
|
|
58
|
+
"@babel/core": "^7.14.6",
|
|
59
|
+
"@babel/preset-env": "^7.14.7",
|
|
61
60
|
"@commitlint/cli": "^12.1.4",
|
|
62
61
|
"@commitlint/config-conventional": "^12.1.4",
|
|
63
|
-
"@types/fs-extra": "^9.0.
|
|
62
|
+
"@types/fs-extra": "^9.0.12",
|
|
64
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.0.6",
|
|
70
69
|
"chokidar": "^3.5.2",
|
|
71
70
|
"cross-env": "^7.0.3",
|
|
72
71
|
"del": "^6.0.0",
|
|
73
|
-
"del-cli": "^
|
|
74
|
-
"eslint": "^7.
|
|
72
|
+
"del-cli": "^4.0.0",
|
|
73
|
+
"eslint": "^7.30.0",
|
|
75
74
|
"eslint-config-prettier": "^8.3.0",
|
|
76
|
-
"eslint-plugin-import": "^2.
|
|
75
|
+
"eslint-plugin-import": "^2.23.4",
|
|
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.1",
|
|
79
|
+
"jest": "^27.0.6",
|
|
80
|
+
"lint-staged": "^11.0.0",
|
|
82
81
|
"npm-run-all": "^4.1.5",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"webpack": "^5.62.1"
|
|
82
|
+
"prettier": "^2.3.2",
|
|
83
|
+
"standard-version": "^9.3.0",
|
|
84
|
+
"stylelint": "^13.13.1",
|
|
85
|
+
"typescript": "^4.3.5",
|
|
86
|
+
"webpack": "^5.44.0"
|
|
89
87
|
},
|
|
90
88
|
"keywords": [
|
|
91
89
|
"stylelint",
|