stylelint-webpack-plugin 2.3.0 → 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/README.md +9 -7
- package/dist/StylelintError.js +2 -8
- package/dist/getStylelint.js +31 -24
- package/dist/index.js +64 -45
- package/dist/linter.js +31 -25
- package/dist/options.js +14 -15
- package/dist/utils.js +19 -26
- package/package.json +23 -24
- package/types/StylelintError.d.ts +8 -0
- package/{declarations → types}/getStylelint.d.ts +37 -17
- package/{declarations → types}/index.d.ts +22 -11
- package/{declarations → types}/linter.d.ts +46 -19
- package/{declarations → types}/options.d.ts +50 -43
- package/{declarations → types}/utils.d.ts +5 -0
- package/{declarations → types}/worker.d.ts +12 -5
- package/declarations/StylelintError.d.ts +0 -2
- package/declarations/cjs.d.ts +0 -3
- package/dist/cjs.js +0 -5
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
npm install stylelint-webpack-plugin --save-dev
|
|
21
|
+
npm install stylelint-webpack-plugin@2 --save-dev
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
**Note**: You also need to install `stylelint` from npm, if you haven't already:
|
|
@@ -27,6 +27,8 @@ npm install stylelint-webpack-plugin --save-dev
|
|
|
27
27
|
npm install stylelint --save-dev
|
|
28
28
|
```
|
|
29
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
|
+
|
|
30
32
|
## Usage
|
|
31
33
|
|
|
32
34
|
In your webpack configuration:
|
|
@@ -181,16 +183,16 @@ You can pass in a different formatter for the output file, if none is passed in
|
|
|
181
183
|
|
|
182
184
|
[MIT](./LICENSE)
|
|
183
185
|
|
|
184
|
-
[npm]: https://img.shields.io/npm/v/stylelint-webpack-plugin.svg
|
|
185
|
-
[npm-url]: https://npmjs.com/package/stylelint-webpack-plugin
|
|
186
|
-
[node]: https://img.shields.io/node/v/stylelint-webpack-plugin.svg
|
|
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
|
|
187
189
|
[node-url]: https://nodejs.org
|
|
188
190
|
[deps]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin.svg
|
|
189
191
|
[deps-url]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin
|
|
190
|
-
[tests]: https://github.com/webpack-contrib/stylelint-webpack-plugin/workflows/stylelint-webpack-plugin/badge.svg
|
|
192
|
+
[tests]: https://github.com/webpack-contrib/stylelint-webpack-plugin/workflows/stylelint-webpack-plugin/badge.svg?branch=2.x
|
|
191
193
|
[tests-url]: https://github.com/webpack-contrib/stylelint-webpack-plugin/actions
|
|
192
|
-
[cover]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin/branch/
|
|
193
|
-
[cover-url]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin
|
|
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
|
|
194
196
|
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
195
197
|
[chat-url]: https://gitter.im/webpack/webpack
|
|
196
198
|
[size]: https://packagephobia.now.sh/badge?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
4
|
/**
|
|
10
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,9 +35,9 @@ 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
42
|
/**
|
|
37
43
|
* @param {Options} options
|
|
@@ -39,10 +45,12 @@ const cache = {};
|
|
|
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
|
};
|
|
@@ -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,
|
|
@@ -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
|
|
@@ -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;
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const {
|
|
4
|
+
isAbsolute,
|
|
5
|
+
join
|
|
6
|
+
} = require('path');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const arrify = require('arrify');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const globby = require('globby');
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const {
|
|
13
|
+
isMatch
|
|
14
|
+
} = require('micromatch');
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
const {
|
|
17
|
+
getOptions
|
|
18
|
+
} = require('./options');
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _linter = _interopRequireDefault(require("./linter"));
|
|
19
|
-
|
|
20
|
-
var _utils = require("./utils");
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
// @ts-ignore
|
|
20
|
+
const linter = require('./linter');
|
|
26
21
|
|
|
22
|
+
const {
|
|
23
|
+
parseFiles,
|
|
24
|
+
parseFoldersToGlobs
|
|
25
|
+
} = require('./utils');
|
|
27
26
|
/** @typedef {import('webpack').Compiler} Compiler */
|
|
28
27
|
|
|
29
28
|
/** @typedef {import('webpack').Module} Module */
|
|
@@ -31,6 +30,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
31
30
|
/** @typedef {import('./options').Options} Options */
|
|
32
31
|
|
|
33
32
|
/** @typedef {Partial<{timestamp:number} | number>} FileSystemInfoEntry */
|
|
33
|
+
|
|
34
|
+
|
|
34
35
|
const STYLELINT_PLUGIN = 'StylelintWebpackPlugin';
|
|
35
36
|
let counter = 0;
|
|
36
37
|
|
|
@@ -40,7 +41,7 @@ class StylelintWebpackPlugin {
|
|
|
40
41
|
*/
|
|
41
42
|
constructor(options = {}) {
|
|
42
43
|
this.key = STYLELINT_PLUGIN;
|
|
43
|
-
this.options =
|
|
44
|
+
this.options = getOptions(options);
|
|
44
45
|
this.run = this.run.bind(this);
|
|
45
46
|
this.startTime = Date.now();
|
|
46
47
|
/** @type {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} */
|
|
@@ -56,11 +57,21 @@ class StylelintWebpackPlugin {
|
|
|
56
57
|
apply(compiler) {
|
|
57
58
|
// Generate key for each compilation,
|
|
58
59
|
// this differentiates one from the other when being cached.
|
|
59
|
-
this.key = compiler.name || `${this.key}_${counter += 1}`;
|
|
60
|
+
this.key = compiler.name || `${this.key}_${counter += 1}`;
|
|
61
|
+
const context = this.getContext(compiler);
|
|
62
|
+
const excludeDefault = ['**/node_modules/**', String(compiler.options.output.path)];
|
|
63
|
+
const options = { ...this.options,
|
|
64
|
+
context,
|
|
65
|
+
exclude: parseFiles(this.options.exclude || excludeDefault, context),
|
|
66
|
+
extensions: arrify(this.options.extensions),
|
|
67
|
+
files: parseFiles(this.options.files || '', context)
|
|
68
|
+
};
|
|
69
|
+
const wanted = parseFoldersToGlobs(options.files, options.extensions);
|
|
70
|
+
const exclude = parseFoldersToGlobs(options.exclude); // If `lintDirtyModulesOnly` is disabled,
|
|
60
71
|
// execute the linter on the build
|
|
61
72
|
|
|
62
73
|
if (!this.options.lintDirtyModulesOnly) {
|
|
63
|
-
compiler.hooks.run.tapPromise(this.key, this.run);
|
|
74
|
+
compiler.hooks.run.tapPromise(this.key, c => this.run(c, options, wanted, exclude));
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
let isFirstRun = this.options.lintDirtyModulesOnly;
|
|
@@ -70,15 +81,18 @@ class StylelintWebpackPlugin {
|
|
|
70
81
|
return Promise.resolve();
|
|
71
82
|
}
|
|
72
83
|
|
|
73
|
-
return this.run(c);
|
|
84
|
+
return this.run(c, options, wanted, exclude);
|
|
74
85
|
});
|
|
75
86
|
}
|
|
76
87
|
/**
|
|
77
88
|
* @param {Compiler} compiler
|
|
89
|
+
* @param {Options} options
|
|
90
|
+
* @param {string[]} wanted
|
|
91
|
+
* @param {string[]} exclude
|
|
78
92
|
*/
|
|
79
93
|
|
|
80
94
|
|
|
81
|
-
async run(compiler) {
|
|
95
|
+
async run(compiler, options, wanted, exclude) {
|
|
82
96
|
// Do not re-hook
|
|
83
97
|
|
|
84
98
|
/* istanbul ignore if */
|
|
@@ -89,17 +103,12 @@ class StylelintWebpackPlugin {
|
|
|
89
103
|
return;
|
|
90
104
|
}
|
|
91
105
|
|
|
92
|
-
const context = this.getContext(compiler);
|
|
93
|
-
const options = { ...this.options,
|
|
94
|
-
exclude: (0, _utils.parseFiles)(this.options.exclude || ['**/node_modules/**', compiler.options.output.path], context),
|
|
95
|
-
extensions: (0, _arrify.default)(this.options.extensions),
|
|
96
|
-
files: (0, _utils.parseFiles)(this.options.files || '', context)
|
|
97
|
-
};
|
|
98
|
-
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions);
|
|
99
|
-
const exclude = (0, _utils.parseFoldersToGlobs)(options.exclude);
|
|
100
106
|
compiler.hooks.thisCompilation.tap(this.key, compilation => {
|
|
101
107
|
/** @type {import('./linter').Linter} */
|
|
102
108
|
let lint;
|
|
109
|
+
/** @type {import('stylelint').InternalApi} */
|
|
110
|
+
|
|
111
|
+
let api;
|
|
103
112
|
/** @type {import('./linter').Reporter} */
|
|
104
113
|
|
|
105
114
|
let report;
|
|
@@ -110,23 +119,34 @@ class StylelintWebpackPlugin {
|
|
|
110
119
|
try {
|
|
111
120
|
({
|
|
112
121
|
lint,
|
|
122
|
+
api,
|
|
113
123
|
report,
|
|
114
124
|
threads
|
|
115
|
-
} = (
|
|
125
|
+
} = linter(this.key, options, compilation));
|
|
116
126
|
} catch (e) {
|
|
117
127
|
compilation.errors.push(e);
|
|
118
128
|
return;
|
|
119
129
|
}
|
|
120
130
|
|
|
121
|
-
compilation.hooks.finishModules.
|
|
122
|
-
|
|
131
|
+
compilation.hooks.finishModules.tapPromise(this.key, async () => {
|
|
132
|
+
/** @type {string[]} */
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
const files = (await Promise.all(this.getFiles(compiler, wanted, exclude).map(async (
|
|
135
|
+
/** @type {string | undefined} */
|
|
136
|
+
file) => {
|
|
137
|
+
try {
|
|
138
|
+
return (await api.isPathIgnored(file)) ? false : file;
|
|
139
|
+
} catch (e) {
|
|
140
|
+
return file;
|
|
141
|
+
}
|
|
142
|
+
}))).filter(file => file !== false);
|
|
123
143
|
|
|
124
144
|
if (threads > 1) {
|
|
125
145
|
for (const file of files) {
|
|
126
|
-
lint(
|
|
146
|
+
lint(parseFiles(file, options.context || ''));
|
|
127
147
|
}
|
|
128
148
|
} else if (files.length > 0) {
|
|
129
|
-
lint(
|
|
149
|
+
lint(parseFiles(files, options.context || ''));
|
|
130
150
|
}
|
|
131
151
|
}); // await and interpret results
|
|
132
152
|
|
|
@@ -173,8 +193,8 @@ class StylelintWebpackPlugin {
|
|
|
173
193
|
return String(compiler.options.context);
|
|
174
194
|
}
|
|
175
195
|
|
|
176
|
-
if (!
|
|
177
|
-
return
|
|
196
|
+
if (!isAbsolute(this.options.context)) {
|
|
197
|
+
return join(String(compiler.options.context), this.options.context);
|
|
178
198
|
}
|
|
179
199
|
|
|
180
200
|
return this.options.context;
|
|
@@ -191,9 +211,9 @@ class StylelintWebpackPlugin {
|
|
|
191
211
|
getFiles(compiler, wanted, exclude) {
|
|
192
212
|
// webpack 5
|
|
193
213
|
if (compiler.modifiedFiles) {
|
|
194
|
-
return Array.from(compiler.modifiedFiles).filter(file =>
|
|
214
|
+
return Array.from(compiler.modifiedFiles).filter(file => isMatch(file, wanted, {
|
|
195
215
|
dot: true
|
|
196
|
-
}) && !
|
|
216
|
+
}) && !isMatch(file, exclude, {
|
|
197
217
|
dot: true
|
|
198
218
|
}));
|
|
199
219
|
} // webpack 4
|
|
@@ -202,14 +222,14 @@ class StylelintWebpackPlugin {
|
|
|
202
222
|
|
|
203
223
|
|
|
204
224
|
if (compiler.fileTimestamps && compiler.fileTimestamps.size > 0) {
|
|
205
|
-
return this.getChangedFiles(compiler.fileTimestamps).filter(file =>
|
|
225
|
+
return this.getChangedFiles(compiler.fileTimestamps).filter(file => isMatch(file, wanted, {
|
|
206
226
|
dot: true
|
|
207
|
-
}) && !
|
|
227
|
+
}) && !isMatch(file, exclude, {
|
|
208
228
|
dot: true
|
|
209
229
|
}));
|
|
210
230
|
}
|
|
211
231
|
|
|
212
|
-
return
|
|
232
|
+
return globby.sync(wanted, {
|
|
213
233
|
dot: true,
|
|
214
234
|
ignore: exclude
|
|
215
235
|
});
|
|
@@ -264,5 +284,4 @@ class StylelintWebpackPlugin {
|
|
|
264
284
|
|
|
265
285
|
}
|
|
266
286
|
|
|
267
|
-
|
|
268
|
-
exports.default = _default;
|
|
287
|
+
module.exports = StylelintWebpackPlugin;
|
package/dist/linter.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const {
|
|
4
|
+
dirname,
|
|
5
|
+
isAbsolute,
|
|
6
|
+
join
|
|
7
|
+
} = require('path');
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const arrify = require('arrify');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _StylelintError = _interopRequireDefault(require("./StylelintError"));
|
|
13
|
-
|
|
14
|
-
var _getStylelint = _interopRequireDefault(require("./getStylelint"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
// @ts-ignore
|
|
11
|
+
const StylelintError = require('./StylelintError');
|
|
19
12
|
|
|
13
|
+
const getStylelint = require('./getStylelint');
|
|
20
14
|
/** @typedef {import('stylelint')} Stylelint */
|
|
21
15
|
|
|
22
16
|
/** @typedef {import('stylelint').LintResult} LintResult */
|
|
23
17
|
|
|
18
|
+
/** @typedef {import('stylelint').InternalApi} InternalApi */
|
|
19
|
+
|
|
24
20
|
/** @typedef {import('webpack').Compiler} Compiler */
|
|
25
21
|
|
|
26
22
|
/** @typedef {import('webpack').Compilation} Compilation */
|
|
@@ -42,17 +38,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
42
38
|
/** @typedef {{[files: string]: LintResult}} LintResultMap */
|
|
43
39
|
|
|
44
40
|
/** @type {WeakMap<Compiler, LintResultMap>} */
|
|
41
|
+
|
|
42
|
+
|
|
45
43
|
const resultStorage = new WeakMap();
|
|
46
44
|
/**
|
|
47
45
|
* @param {string|undefined} key
|
|
48
46
|
* @param {Options} options
|
|
49
47
|
* @param {Compilation} compilation
|
|
50
|
-
* @returns {{lint: Linter, report: Reporter, threads: number}}
|
|
48
|
+
* @returns {{api: InternalApi, lint: Linter, report: Reporter, threads: number}}
|
|
51
49
|
*/
|
|
52
50
|
|
|
53
51
|
function linter(key, options, compilation) {
|
|
54
52
|
/** @type {Stylelint} */
|
|
55
53
|
let stylelint;
|
|
54
|
+
/** @type {InternalApi} */
|
|
55
|
+
|
|
56
|
+
let api;
|
|
56
57
|
/** @type {(files: string|string[]) => Promise<LintResult[]>} */
|
|
57
58
|
|
|
58
59
|
let lintFiles;
|
|
@@ -70,16 +71,18 @@ function linter(key, options, compilation) {
|
|
|
70
71
|
try {
|
|
71
72
|
({
|
|
72
73
|
stylelint,
|
|
74
|
+
api,
|
|
73
75
|
lintFiles,
|
|
74
76
|
cleanup,
|
|
75
77
|
threads
|
|
76
|
-
} = (
|
|
78
|
+
} = getStylelint(key, options));
|
|
77
79
|
} catch (e) {
|
|
78
|
-
throw new
|
|
80
|
+
throw new StylelintError(e.message);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
return {
|
|
82
84
|
lint,
|
|
85
|
+
api,
|
|
83
86
|
report,
|
|
84
87
|
threads
|
|
85
88
|
};
|
|
@@ -88,12 +91,13 @@ function linter(key, options, compilation) {
|
|
|
88
91
|
*/
|
|
89
92
|
|
|
90
93
|
function lint(files) {
|
|
91
|
-
for (const file of (
|
|
94
|
+
for (const file of arrify(files)) {
|
|
92
95
|
delete crossRunResultStorage[file];
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
rawResults.push(lintFiles(files).catch(e => {
|
|
96
|
-
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
compilation.errors.push(new StylelintError(e.message));
|
|
97
101
|
return [];
|
|
98
102
|
}));
|
|
99
103
|
}
|
|
@@ -149,7 +153,7 @@ function linter(key, options, compilation) {
|
|
|
149
153
|
} = compiler.outputFileSystem; // ensure directory exists
|
|
150
154
|
// @ts-ignore - the types for `outputFileSystem` are missing the 3 arg overload
|
|
151
155
|
|
|
152
|
-
mkdir(
|
|
156
|
+
mkdir(dirname(name), {
|
|
153
157
|
recursive: true
|
|
154
158
|
}, err => {
|
|
155
159
|
/* istanbul ignore if */
|
|
@@ -169,8 +173,8 @@ function linter(key, options, compilation) {
|
|
|
169
173
|
filePath
|
|
170
174
|
} = outputReport;
|
|
171
175
|
|
|
172
|
-
if (!
|
|
173
|
-
filePath =
|
|
176
|
+
if (!isAbsolute(filePath)) {
|
|
177
|
+
filePath = join(compiler.outputPath, filePath);
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
await save(filePath, content);
|
|
@@ -189,11 +193,11 @@ function formatResults(formatter, results) {
|
|
|
189
193
|
let warnings;
|
|
190
194
|
|
|
191
195
|
if (results.warnings.length > 0) {
|
|
192
|
-
warnings = new
|
|
196
|
+
warnings = new StylelintError(formatter(results.warnings));
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
if (results.errors.length > 0) {
|
|
196
|
-
errors = new
|
|
200
|
+
errors = new StylelintError(formatter(results.errors));
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
return {
|
|
@@ -297,4 +301,6 @@ function getResultStorage({
|
|
|
297
301
|
}
|
|
298
302
|
|
|
299
303
|
return storage;
|
|
300
|
-
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
module.exports = linter;
|
package/dist/options.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.getOptions = getOptions;
|
|
7
|
-
exports.getStylelintOptions = getStylelintOptions;
|
|
3
|
+
const {
|
|
4
|
+
validate
|
|
5
|
+
} = require('schema-utils'); // @ts-ignore
|
|
8
6
|
|
|
9
|
-
var _schemaUtils = require("schema-utils");
|
|
10
|
-
|
|
11
|
-
var _options = _interopRequireDefault(require("./options.json"));
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
// @ts-ignore
|
|
16
7
|
|
|
8
|
+
const schema = require('./options.json');
|
|
17
9
|
/** @typedef {import("stylelint")} stylelint */
|
|
18
10
|
|
|
19
11
|
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
|
|
@@ -50,6 +42,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
50
42
|
* @param {Options} pluginOptions
|
|
51
43
|
* @returns {Partial<PluginOptions>}
|
|
52
44
|
*/
|
|
45
|
+
|
|
46
|
+
|
|
53
47
|
function getOptions(pluginOptions) {
|
|
54
48
|
const options = {
|
|
55
49
|
extensions: ['css', 'scss', 'sass'],
|
|
@@ -63,7 +57,7 @@ function getOptions(pluginOptions) {
|
|
|
63
57
|
} : {})
|
|
64
58
|
}; // @ts-ignore
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
validate(schema, options, {
|
|
67
61
|
name: 'Stylelint Webpack Plugin',
|
|
68
62
|
baseDataPath: 'options'
|
|
69
63
|
});
|
|
@@ -83,7 +77,7 @@ function getStylelintOptions(pluginOptions) {
|
|
|
83
77
|
files,
|
|
84
78
|
formatter,
|
|
85
79
|
...stylelintOnlyOptions
|
|
86
|
-
} =
|
|
80
|
+
} = schema.properties; // No need to guard the for-in because schema.properties has hardcoded keys.
|
|
87
81
|
// eslint-disable-next-line guard-for-in
|
|
88
82
|
|
|
89
83
|
for (const option in stylelintOnlyOptions) {
|
|
@@ -92,4 +86,9 @@ function getStylelintOptions(pluginOptions) {
|
|
|
92
86
|
}
|
|
93
87
|
|
|
94
88
|
return stylelintOptions;
|
|
95
|
-
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
getOptions,
|
|
93
|
+
getStylelintOptions
|
|
94
|
+
};
|
package/dist/utils.js
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.jsonStringifyReplacerSortKeys = void 0;
|
|
7
|
-
exports.parseFiles = parseFiles;
|
|
8
|
-
exports.parseFoldersToGlobs = parseFoldersToGlobs;
|
|
3
|
+
const {
|
|
4
|
+
resolve
|
|
5
|
+
} = require('path');
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
const {
|
|
8
|
+
statSync
|
|
9
|
+
} = require('fs');
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
|
15
|
-
|
|
16
|
-
var _arrify = _interopRequireDefault(require("arrify"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
// @ts-ignore
|
|
11
|
+
const normalizePath = require('normalize-path');
|
|
22
12
|
|
|
13
|
+
const arrify = require('arrify');
|
|
23
14
|
/**
|
|
24
15
|
* @param {string|(string|undefined)[]} files
|
|
25
16
|
* @param {string} context
|
|
26
17
|
* @returns {string[]}
|
|
27
18
|
*/
|
|
19
|
+
|
|
20
|
+
|
|
28
21
|
function parseFiles(files, context) {
|
|
29
|
-
return (
|
|
30
|
-
/** @type {string} */
|
|
31
|
-
file) => typeof file === 'string').map((
|
|
32
|
-
/** @type {string} */
|
|
33
|
-
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file)));
|
|
22
|
+
return arrify(files).filter(file => typeof file === 'string').map(file => normalizePath(resolve(context, file || '')));
|
|
34
23
|
}
|
|
35
24
|
/**
|
|
36
25
|
* @param {string|string[]} patterns
|
|
@@ -40,17 +29,17 @@ function parseFiles(files, context) {
|
|
|
40
29
|
|
|
41
30
|
|
|
42
31
|
function parseFoldersToGlobs(patterns, extensions = []) {
|
|
43
|
-
const extensionsList = (
|
|
32
|
+
const extensionsList = arrify(extensions);
|
|
44
33
|
const [prefix, postfix] = extensionsList.length > 1 ? ['{', '}'] : ['', ''];
|
|
45
34
|
const extensionsGlob = extensionsList.map((
|
|
46
35
|
/** @type {string} */
|
|
47
36
|
extension) => extension.replace(/^\./u, '')).join(',');
|
|
48
|
-
return (
|
|
37
|
+
return arrify(patterns).map((
|
|
49
38
|
/** @type {string} */
|
|
50
39
|
pattern) => {
|
|
51
40
|
try {
|
|
52
41
|
// The patterns are absolute because they are prepended with the context.
|
|
53
|
-
const stats =
|
|
42
|
+
const stats = statSync(pattern);
|
|
54
43
|
/* istanbul ignore else */
|
|
55
44
|
|
|
56
45
|
if (stats.isDirectory()) {
|
|
@@ -83,4 +72,8 @@ const jsonStringifyReplacerSortKeys = (_, value) => {
|
|
|
83
72
|
return value instanceof Object && !(value instanceof Array) ? Object.keys(value).sort().reduce(insert, {}) : value;
|
|
84
73
|
};
|
|
85
74
|
|
|
86
|
-
exports
|
|
75
|
+
module.exports = {
|
|
76
|
+
parseFiles,
|
|
77
|
+
parseFoldersToGlobs,
|
|
78
|
+
jsonStringifyReplacerSortKeys
|
|
79
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-webpack-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A Stylelint plugin for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/stylelint-webpack-plugin",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"type": "opencollective",
|
|
12
12
|
"url": "https://opencollective.com/webpack"
|
|
13
13
|
},
|
|
14
|
-
"main": "dist/
|
|
15
|
-
"types": "
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "types/index.d.ts",
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">= 10.13.0"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"start": "npm run build -- -w",
|
|
21
|
-
"clean": "del-cli dist
|
|
21
|
+
"clean": "del-cli dist types",
|
|
22
22
|
"prebuild": "npm run clean",
|
|
23
|
-
"build:types": "tsc --declaration --emitDeclarationOnly --outDir
|
|
23
|
+
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write",
|
|
24
24
|
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
|
|
25
25
|
"build": "npm-run-all -p \"build:**\"",
|
|
26
26
|
"commitlint": "commitlint --from=master",
|
|
@@ -39,25 +39,24 @@
|
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"dist",
|
|
42
|
-
"
|
|
42
|
+
"types"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
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.3",
|
|
50
49
|
"arrify": "^2.0.1",
|
|
51
|
-
"jest-worker": "^27.3.1",
|
|
52
50
|
"globby": "^11.0.4",
|
|
53
|
-
"
|
|
51
|
+
"jest-worker": "^28.1.0",
|
|
52
|
+
"micromatch": "^4.0.5",
|
|
54
53
|
"normalize-path": "^3.0.0",
|
|
55
54
|
"schema-utils": "^3.1.1"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
57
|
+
"@babel/cli": "^7.17.10",
|
|
58
|
+
"@babel/core": "^7.18.0",
|
|
59
|
+
"@babel/preset-env": "^7.18.0",
|
|
61
60
|
"@commitlint/cli": "^12.1.4",
|
|
62
61
|
"@commitlint/config-conventional": "^12.1.4",
|
|
63
62
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -66,26 +65,26 @@
|
|
|
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": "^
|
|
70
|
-
"chokidar": "^3.5.
|
|
68
|
+
"babel-jest": "^28.1.0",
|
|
69
|
+
"chokidar": "^3.5.3",
|
|
71
70
|
"cross-env": "^7.0.3",
|
|
72
|
-
"del": "^6.
|
|
71
|
+
"del": "^6.1.0",
|
|
73
72
|
"del-cli": "^3.0.1",
|
|
74
73
|
"eslint": "^7.32.0",
|
|
75
|
-
"eslint-config-prettier": "^8.
|
|
76
|
-
"eslint-plugin-import": "^2.
|
|
74
|
+
"eslint-config-prettier": "^8.5.0",
|
|
75
|
+
"eslint-plugin-import": "^2.26.0",
|
|
77
76
|
"file-loader": "^6.2.0",
|
|
78
77
|
"fs-extra": "^9.1.0",
|
|
79
78
|
"husky": "^6.0.0",
|
|
80
|
-
"jest": "^
|
|
81
|
-
"lint-staged": "^
|
|
79
|
+
"jest": "^28.1.0",
|
|
80
|
+
"lint-staged": "^11.2.6",
|
|
82
81
|
"npm-run-all": "^4.1.5",
|
|
83
82
|
"postcss-scss": "^3.0.5",
|
|
84
|
-
"prettier": "^2.
|
|
85
|
-
"standard-version": "^9.
|
|
86
|
-
"stylelint": "^14.
|
|
87
|
-
"typescript": "^4.
|
|
88
|
-
"webpack": "^5.
|
|
83
|
+
"prettier": "^2.6.2",
|
|
84
|
+
"standard-version": "^9.5.0",
|
|
85
|
+
"stylelint": "^14.8.2",
|
|
86
|
+
"typescript": "^4.6.4",
|
|
87
|
+
"webpack": "^5.72.1"
|
|
89
88
|
},
|
|
90
89
|
"keywords": [
|
|
91
90
|
"stylelint",
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
/// <reference types="stylelint" />
|
|
2
|
+
export = getStylelint;
|
|
2
3
|
/**
|
|
3
4
|
* @param {string|undefined} key
|
|
4
5
|
* @param {Options} options
|
|
5
6
|
* @returns {Linter}
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
declare function getStylelint(
|
|
8
9
|
key: string | undefined,
|
|
9
10
|
{ threads, ...options }: Options
|
|
10
11
|
): Linter;
|
|
11
|
-
|
|
12
|
+
declare namespace getStylelint {
|
|
13
|
+
export {
|
|
14
|
+
Stylelint,
|
|
15
|
+
LintResult,
|
|
16
|
+
Options,
|
|
17
|
+
AsyncTask,
|
|
18
|
+
LintTask,
|
|
19
|
+
Linter,
|
|
20
|
+
Worker,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
type Options = import('./options').Options;
|
|
24
|
+
type Linter = {
|
|
25
|
+
api: import('stylelint').InternalApi;
|
|
26
|
+
stylelint: Stylelint;
|
|
27
|
+
lintFiles: LintTask;
|
|
28
|
+
cleanup: AsyncTask;
|
|
29
|
+
threads: number;
|
|
30
|
+
};
|
|
31
|
+
type Stylelint = import('postcss').PluginCreator<
|
|
12
32
|
import('stylelint').PostcssPluginOptions
|
|
13
33
|
> & {
|
|
14
34
|
lint: (
|
|
@@ -30,6 +50,15 @@ export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
30
50
|
createLinter: (
|
|
31
51
|
options: import('stylelint').LinterOptions
|
|
32
52
|
) => import('stylelint').InternalApi;
|
|
53
|
+
resolveConfig: (
|
|
54
|
+
filePath: string,
|
|
55
|
+
options?:
|
|
56
|
+
| Pick<
|
|
57
|
+
import('stylelint').LinterOptions,
|
|
58
|
+
'cwd' | 'config' | 'configFile' | 'configBasedir'
|
|
59
|
+
>
|
|
60
|
+
| undefined
|
|
61
|
+
) => Promise<import('stylelint').Config | undefined>;
|
|
33
62
|
utils: {
|
|
34
63
|
report: (problem: import('stylelint').Problem) => void;
|
|
35
64
|
ruleMessages: <
|
|
@@ -48,25 +77,16 @@ export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
48
77
|
options: {
|
|
49
78
|
ruleName: string;
|
|
50
79
|
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
51
|
-
root: import('
|
|
80
|
+
root: import('postcss').Root;
|
|
52
81
|
},
|
|
53
|
-
callback: (
|
|
54
|
-
warning: import('stylelint/node_modules/postcss').Warning
|
|
55
|
-
) => void
|
|
82
|
+
callback: (warning: import('postcss').Warning) => void
|
|
56
83
|
) => void;
|
|
57
84
|
};
|
|
58
85
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export type Worker = JestWorker & {
|
|
86
|
+
type LintResult = import('stylelint').LintResult;
|
|
87
|
+
type AsyncTask = () => Promise<void>;
|
|
88
|
+
type LintTask = (files: string | string[]) => Promise<LintResult[]>;
|
|
89
|
+
type Worker = JestWorker & {
|
|
64
90
|
lintFiles: LintTask;
|
|
65
91
|
};
|
|
66
|
-
export type Linter = {
|
|
67
|
-
stylelint: Stylelint;
|
|
68
|
-
lintFiles: LintTask;
|
|
69
|
-
cleanup: AsyncTask;
|
|
70
|
-
threads: number;
|
|
71
|
-
};
|
|
72
92
|
import { Worker as JestWorker } from 'jest-worker';
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type Compiler = import('webpack').Compiler;
|
|
3
|
-
export type Module = import('webpack').Module;
|
|
4
|
-
export type Options = import('./options').Options;
|
|
5
|
-
export type FileSystemInfoEntry = Partial<
|
|
6
|
-
| {
|
|
7
|
-
timestamp: number;
|
|
8
|
-
}
|
|
9
|
-
| number
|
|
10
|
-
>;
|
|
1
|
+
export = StylelintWebpackPlugin;
|
|
11
2
|
declare class StylelintWebpackPlugin {
|
|
12
3
|
/**
|
|
13
4
|
* @param {Options} options
|
|
@@ -17,8 +8,16 @@ declare class StylelintWebpackPlugin {
|
|
|
17
8
|
options: Partial<import('./options').PluginOptions>;
|
|
18
9
|
/**
|
|
19
10
|
* @param {Compiler} compiler
|
|
11
|
+
* @param {Options} options
|
|
12
|
+
* @param {string[]} wanted
|
|
13
|
+
* @param {string[]} exclude
|
|
20
14
|
*/
|
|
21
|
-
run(
|
|
15
|
+
run(
|
|
16
|
+
compiler: Compiler,
|
|
17
|
+
options: Options,
|
|
18
|
+
wanted: string[],
|
|
19
|
+
exclude: string[]
|
|
20
|
+
): Promise<void>;
|
|
22
21
|
startTime: number;
|
|
23
22
|
/** @type {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} */
|
|
24
23
|
prevTimestamps: ReadonlyMap<
|
|
@@ -54,3 +53,15 @@ declare class StylelintWebpackPlugin {
|
|
|
54
53
|
>
|
|
55
54
|
): string[];
|
|
56
55
|
}
|
|
56
|
+
declare namespace StylelintWebpackPlugin {
|
|
57
|
+
export { Compiler, Module, Options, FileSystemInfoEntry };
|
|
58
|
+
}
|
|
59
|
+
type Compiler = import('webpack').Compiler;
|
|
60
|
+
type Options = import('./options').Options;
|
|
61
|
+
type FileSystemInfoEntry = Partial<
|
|
62
|
+
| {
|
|
63
|
+
timestamp: number;
|
|
64
|
+
}
|
|
65
|
+
| number
|
|
66
|
+
>;
|
|
67
|
+
type Module = import('webpack').Module;
|
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
/// <reference types="stylelint" />
|
|
2
|
+
export = linter;
|
|
2
3
|
/**
|
|
3
4
|
* @param {string|undefined} key
|
|
4
5
|
* @param {Options} options
|
|
5
6
|
* @param {Compilation} compilation
|
|
6
|
-
* @returns {{lint: Linter, report: Reporter, threads: number}}
|
|
7
|
+
* @returns {{api: InternalApi, lint: Linter, report: Reporter, threads: number}}
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
declare function linter(
|
|
9
10
|
key: string | undefined,
|
|
10
11
|
options: Options,
|
|
11
12
|
compilation: Compilation
|
|
12
13
|
): {
|
|
14
|
+
api: InternalApi;
|
|
13
15
|
lint: Linter;
|
|
14
16
|
report: Reporter;
|
|
15
17
|
threads: number;
|
|
16
18
|
};
|
|
17
|
-
|
|
19
|
+
declare namespace linter {
|
|
20
|
+
export {
|
|
21
|
+
Stylelint,
|
|
22
|
+
LintResult,
|
|
23
|
+
InternalApi,
|
|
24
|
+
Compiler,
|
|
25
|
+
Compilation,
|
|
26
|
+
Options,
|
|
27
|
+
FormatterType,
|
|
28
|
+
FormatterFunction,
|
|
29
|
+
GenerateReport,
|
|
30
|
+
Report,
|
|
31
|
+
Reporter,
|
|
32
|
+
Linter,
|
|
33
|
+
LintResultMap,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
type Options = import('./options').Options;
|
|
37
|
+
type Compilation = import('webpack').Compilation;
|
|
38
|
+
type InternalApi = import('stylelint').InternalApi;
|
|
39
|
+
type Linter = (files: string | string[]) => void;
|
|
40
|
+
type Reporter = () => Promise<Report>;
|
|
41
|
+
type Stylelint = import('postcss').PluginCreator<
|
|
18
42
|
import('stylelint').PostcssPluginOptions
|
|
19
43
|
> & {
|
|
20
44
|
lint: (
|
|
@@ -36,6 +60,15 @@ export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
36
60
|
createLinter: (
|
|
37
61
|
options: import('stylelint').LinterOptions
|
|
38
62
|
) => import('stylelint').InternalApi;
|
|
63
|
+
resolveConfig: (
|
|
64
|
+
filePath: string,
|
|
65
|
+
options?:
|
|
66
|
+
| Pick<
|
|
67
|
+
import('stylelint').LinterOptions,
|
|
68
|
+
'cwd' | 'config' | 'configFile' | 'configBasedir'
|
|
69
|
+
>
|
|
70
|
+
| undefined
|
|
71
|
+
) => Promise<import('stylelint').Config | undefined>;
|
|
39
72
|
utils: {
|
|
40
73
|
report: (problem: import('stylelint').Problem) => void;
|
|
41
74
|
ruleMessages: <
|
|
@@ -54,29 +87,23 @@ export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
54
87
|
options: {
|
|
55
88
|
ruleName: string;
|
|
56
89
|
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
57
|
-
root: import('
|
|
90
|
+
root: import('postcss').Root;
|
|
58
91
|
},
|
|
59
|
-
callback: (
|
|
60
|
-
warning: import('stylelint/node_modules/postcss').Warning
|
|
61
|
-
) => void
|
|
92
|
+
callback: (warning: import('postcss').Warning) => void
|
|
62
93
|
) => void;
|
|
63
94
|
};
|
|
64
95
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export type GenerateReport = (compilation: Compilation) => Promise<void>;
|
|
72
|
-
export type Report = {
|
|
96
|
+
type LintResult = import('stylelint').LintResult;
|
|
97
|
+
type Compiler = import('webpack').Compiler;
|
|
98
|
+
type FormatterType = import('./options').FormatterType;
|
|
99
|
+
type FormatterFunction = (results: LintResult[]) => string;
|
|
100
|
+
type GenerateReport = (compilation: Compilation) => Promise<void>;
|
|
101
|
+
type Report = {
|
|
73
102
|
errors?: StylelintError;
|
|
74
103
|
warnings?: StylelintError;
|
|
75
104
|
generateReportAsset?: GenerateReport;
|
|
76
105
|
};
|
|
77
|
-
|
|
78
|
-
export type Linter = (files: string | string[]) => void;
|
|
79
|
-
export type LintResultMap = {
|
|
106
|
+
type LintResultMap = {
|
|
80
107
|
[files: string]: import('stylelint').LintResult;
|
|
81
108
|
};
|
|
82
|
-
import StylelintError
|
|
109
|
+
import StylelintError = require('./StylelintError');
|
|
@@ -1,43 +1,5 @@
|
|
|
1
1
|
/// <reference types="stylelint" />
|
|
2
|
-
|
|
3
|
-
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
|
|
4
|
-
/** @typedef {import("stylelint").FormatterType} FormatterType */
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} OutputReport
|
|
7
|
-
* @property {string=} filePath
|
|
8
|
-
* @property {FormatterType=} formatter
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {Object} PluginOptions
|
|
12
|
-
* @property {string} context
|
|
13
|
-
* @property {boolean} emitError
|
|
14
|
-
* @property {boolean} emitWarning
|
|
15
|
-
* @property {string|string[]=} exclude
|
|
16
|
-
* @property {string|string[]} extensions
|
|
17
|
-
* @property {boolean} failOnError
|
|
18
|
-
* @property {boolean} failOnWarning
|
|
19
|
-
* @property {string|string[]} files
|
|
20
|
-
* @property {FormatterType} formatter
|
|
21
|
-
* @property {boolean} lintDirtyModulesOnly
|
|
22
|
-
* @property {boolean} quiet
|
|
23
|
-
* @property {string} stylelintPath
|
|
24
|
-
* @property {OutputReport} outputReport
|
|
25
|
-
* @property {number|boolean=} threads
|
|
26
|
-
*/
|
|
27
|
-
/** @typedef {Partial<PluginOptions & StylelintOptions>} Options */
|
|
28
|
-
/**
|
|
29
|
-
* @param {Options} pluginOptions
|
|
30
|
-
* @returns {Partial<PluginOptions>}
|
|
31
|
-
*/
|
|
32
|
-
export function getOptions(pluginOptions: Options): Partial<PluginOptions>;
|
|
33
|
-
/**
|
|
34
|
-
* @param {Options} pluginOptions
|
|
35
|
-
* @returns {Partial<StylelintOptions>}
|
|
36
|
-
*/
|
|
37
|
-
export function getStylelintOptions(
|
|
38
|
-
pluginOptions: Options
|
|
39
|
-
): Partial<StylelintOptions>;
|
|
40
|
-
export type stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
2
|
+
export type stylelint = import('postcss').PluginCreator<
|
|
41
3
|
import('stylelint').PostcssPluginOptions
|
|
42
4
|
> & {
|
|
43
5
|
lint: (
|
|
@@ -59,6 +21,15 @@ export type stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
59
21
|
createLinter: (
|
|
60
22
|
options: import('stylelint').LinterOptions
|
|
61
23
|
) => import('stylelint').InternalApi;
|
|
24
|
+
resolveConfig: (
|
|
25
|
+
filePath: string,
|
|
26
|
+
options?:
|
|
27
|
+
| Pick<
|
|
28
|
+
import('stylelint').LinterOptions,
|
|
29
|
+
'cwd' | 'config' | 'configFile' | 'configBasedir'
|
|
30
|
+
>
|
|
31
|
+
| undefined
|
|
32
|
+
) => Promise<import('stylelint').Config | undefined>;
|
|
62
33
|
utils: {
|
|
63
34
|
report: (problem: import('stylelint').Problem) => void;
|
|
64
35
|
ruleMessages: <
|
|
@@ -77,11 +48,9 @@ export type stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
77
48
|
options: {
|
|
78
49
|
ruleName: string;
|
|
79
50
|
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
80
|
-
root: import('
|
|
51
|
+
root: import('postcss').Root;
|
|
81
52
|
},
|
|
82
|
-
callback: (
|
|
83
|
-
warning: import('stylelint/node_modules/postcss').Warning
|
|
84
|
-
) => void
|
|
53
|
+
callback: (warning: import('postcss').Warning) => void
|
|
85
54
|
) => void;
|
|
86
55
|
};
|
|
87
56
|
};
|
|
@@ -108,3 +77,41 @@ export type PluginOptions = {
|
|
|
108
77
|
threads?: (number | boolean) | undefined;
|
|
109
78
|
};
|
|
110
79
|
export type Options = Partial<PluginOptions & StylelintOptions>;
|
|
80
|
+
/** @typedef {import("stylelint")} stylelint */
|
|
81
|
+
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
|
|
82
|
+
/** @typedef {import("stylelint").FormatterType} FormatterType */
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {Object} OutputReport
|
|
85
|
+
* @property {string=} filePath
|
|
86
|
+
* @property {FormatterType=} formatter
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {Object} PluginOptions
|
|
90
|
+
* @property {string} context
|
|
91
|
+
* @property {boolean} emitError
|
|
92
|
+
* @property {boolean} emitWarning
|
|
93
|
+
* @property {string|string[]=} exclude
|
|
94
|
+
* @property {string|string[]} extensions
|
|
95
|
+
* @property {boolean} failOnError
|
|
96
|
+
* @property {boolean} failOnWarning
|
|
97
|
+
* @property {string|string[]} files
|
|
98
|
+
* @property {FormatterType} formatter
|
|
99
|
+
* @property {boolean} lintDirtyModulesOnly
|
|
100
|
+
* @property {boolean} quiet
|
|
101
|
+
* @property {string} stylelintPath
|
|
102
|
+
* @property {OutputReport} outputReport
|
|
103
|
+
* @property {number|boolean=} threads
|
|
104
|
+
*/
|
|
105
|
+
/** @typedef {Partial<PluginOptions & StylelintOptions>} Options */
|
|
106
|
+
/**
|
|
107
|
+
* @param {Options} pluginOptions
|
|
108
|
+
* @returns {Partial<PluginOptions>}
|
|
109
|
+
*/
|
|
110
|
+
export function getOptions(pluginOptions: Options): Partial<PluginOptions>;
|
|
111
|
+
/**
|
|
112
|
+
* @param {Options} pluginOptions
|
|
113
|
+
* @returns {Partial<StylelintOptions>}
|
|
114
|
+
*/
|
|
115
|
+
export function getStylelintOptions(
|
|
116
|
+
pluginOptions: Options
|
|
117
|
+
): Partial<StylelintOptions>;
|
|
@@ -16,4 +16,9 @@ export function parseFoldersToGlobs(
|
|
|
16
16
|
patterns: string | string[],
|
|
17
17
|
extensions?: string | string[]
|
|
18
18
|
): string[];
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param {string} _ key, but unused
|
|
22
|
+
* @param {any} value
|
|
23
|
+
*/
|
|
19
24
|
export function jsonStringifyReplacerSortKeys(_: string, value: any): any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="stylelint" />
|
|
2
|
-
export type Stylelint = import('
|
|
2
|
+
export type Stylelint = import('postcss').PluginCreator<
|
|
3
3
|
import('stylelint').PostcssPluginOptions
|
|
4
4
|
> & {
|
|
5
5
|
lint: (
|
|
@@ -21,6 +21,15 @@ export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
21
21
|
createLinter: (
|
|
22
22
|
options: import('stylelint').LinterOptions
|
|
23
23
|
) => import('stylelint').InternalApi;
|
|
24
|
+
resolveConfig: (
|
|
25
|
+
filePath: string,
|
|
26
|
+
options?:
|
|
27
|
+
| Pick<
|
|
28
|
+
import('stylelint').LinterOptions,
|
|
29
|
+
'cwd' | 'config' | 'configFile' | 'configBasedir'
|
|
30
|
+
>
|
|
31
|
+
| undefined
|
|
32
|
+
) => Promise<import('stylelint').Config | undefined>;
|
|
24
33
|
utils: {
|
|
25
34
|
report: (problem: import('stylelint').Problem) => void;
|
|
26
35
|
ruleMessages: <
|
|
@@ -39,11 +48,9 @@ export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
|
|
|
39
48
|
options: {
|
|
40
49
|
ruleName: string;
|
|
41
50
|
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
|
|
42
|
-
root: import('
|
|
51
|
+
root: import('postcss').Root;
|
|
43
52
|
},
|
|
44
|
-
callback: (
|
|
45
|
-
warning: import('stylelint/node_modules/postcss').Warning
|
|
46
|
-
) => void
|
|
53
|
+
callback: (warning: import('postcss').Warning) => void
|
|
47
54
|
) => void;
|
|
48
55
|
};
|
|
49
56
|
};
|
package/declarations/cjs.d.ts
DELETED