stylelint-webpack-plugin 5.0.0 → 5.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 +50 -41
- package/dist/StylelintError.js +3 -3
- package/dist/getStylelint.js +39 -38
- package/dist/index.js +39 -58
- package/dist/linter.js +172 -180
- package/dist/options.js +30 -31
- package/dist/utils.js +51 -51
- package/dist/worker.js +43 -23
- package/package.json +59 -52
- package/types/StylelintError.d.ts +1 -1
- package/types/getStylelint.d.ts +19 -17
- package/types/index.d.ts +13 -14
- package/types/linter.d.ts +18 -16
- package/types/options.d.ts +72 -24
- package/types/utils.d.ts +37 -30
- package/types/worker.d.ts +22 -3
package/dist/utils.js
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// eslint-disable-next-line jsdoc/no-restricted-syntax
|
|
4
|
+
/** @typedef {any} EXPECTED_ANY */
|
|
5
|
+
|
|
6
6
|
const {
|
|
7
7
|
statSync
|
|
8
|
-
} = require(
|
|
9
|
-
const
|
|
8
|
+
} = require("node:fs");
|
|
9
|
+
const {
|
|
10
|
+
resolve
|
|
11
|
+
} = require("node:path");
|
|
12
|
+
const normalizePath = require("normalize-path");
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* @template T
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
? T[]
|
|
23
|
-
: [T]
|
|
24
|
-
}
|
|
16
|
+
* @typedef {T extends (null | undefined)
|
|
17
|
+
* ? []
|
|
18
|
+
* : T extends string
|
|
19
|
+
* ? [string]
|
|
20
|
+
* : T extends readonly unknown[]
|
|
21
|
+
* ? T
|
|
22
|
+
* : T extends Iterable<infer T>
|
|
23
|
+
* ? T[]
|
|
24
|
+
* : [T]} ArrifyResult
|
|
25
25
|
*/
|
|
26
|
+
|
|
26
27
|
/* istanbul ignore next */
|
|
28
|
+
/**
|
|
29
|
+
* @template T
|
|
30
|
+
* @param {T} value value
|
|
31
|
+
* @returns {ArrifyResult<T>} array of values
|
|
32
|
+
*/
|
|
27
33
|
function arrify(value) {
|
|
28
|
-
// eslint-disable-next-line no-undefined
|
|
29
34
|
if (value === null || value === undefined) {
|
|
30
|
-
|
|
31
|
-
return [];
|
|
35
|
+
return /** @type {ArrifyResult<T>} */[];
|
|
32
36
|
}
|
|
33
37
|
if (Array.isArray(value)) {
|
|
34
|
-
|
|
35
|
-
return value;
|
|
38
|
+
return /** @type {ArrifyResult<T>} */value;
|
|
36
39
|
}
|
|
37
|
-
if (typeof value ===
|
|
38
|
-
|
|
39
|
-
return [value];
|
|
40
|
+
if (typeof value === "string") {
|
|
41
|
+
return /** @type {ArrifyResult<T>} */[value];
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
// @ts-
|
|
43
|
-
if (typeof value[Symbol.iterator] ===
|
|
44
|
-
// @ts-
|
|
44
|
+
// @ts-expect-error need better types
|
|
45
|
+
if (typeof value[Symbol.iterator] === "function") {
|
|
46
|
+
// @ts-expect-error need better types
|
|
45
47
|
return [...value];
|
|
46
48
|
}
|
|
47
|
-
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
return [value];
|
|
49
|
+
return /** @type {ArrifyResult<T>} */[value];
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* @param {string|string[]} files
|
|
54
|
-
* @param {string} context
|
|
55
|
-
* @returns {string[]}
|
|
53
|
+
* @param {string | string[]} files files
|
|
54
|
+
* @param {string} context context
|
|
55
|
+
* @returns {string[]} normalized paths
|
|
56
56
|
*/
|
|
57
57
|
function parseFiles(files, context) {
|
|
58
|
-
return arrify(files).map((
|
|
58
|
+
return arrify(files).map((/** @type {string} */file) => normalizePath(resolve(context, file)));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @param {string|string[]} patterns
|
|
63
|
-
* @param {string|string[]} extensions
|
|
64
|
-
* @returns {string[]}
|
|
62
|
+
* @param {string | string[]} patterns patterns
|
|
63
|
+
* @param {string | string[]} extensions extensions
|
|
64
|
+
* @returns {string[]} globs
|
|
65
65
|
*/
|
|
66
66
|
function parseFoldersToGlobs(patterns, extensions = []) {
|
|
67
67
|
const extensionsList = arrify(extensions);
|
|
68
|
-
const [prefix, postfix] = extensionsList.length > 1 ? [
|
|
69
|
-
const extensionsGlob = extensionsList.map((
|
|
70
|
-
return arrify(patterns).map((
|
|
68
|
+
const [prefix, postfix] = extensionsList.length > 1 ? ["{", "}"] : ["", ""];
|
|
69
|
+
const extensionsGlob = extensionsList.map((/** @type {string} */extension) => extension.replace(/^\./u, "")).join(",");
|
|
70
|
+
return arrify(patterns).map((/** @type {string} */pattern) => {
|
|
71
71
|
try {
|
|
72
72
|
// The patterns are absolute because they are prepended with the context.
|
|
73
73
|
const stats = statSync(pattern);
|
|
74
74
|
/* istanbul ignore else */
|
|
75
75
|
if (stats.isDirectory()) {
|
|
76
|
-
return pattern.replace(/[/\\]*?$/u, `/**${extensionsGlob ? `/*.${prefix + extensionsGlob + postfix}` :
|
|
76
|
+
return pattern.replace(/[/\\]*?$/u, `/**${extensionsGlob ? `/*.${prefix + extensionsGlob + postfix}` : ""}`);
|
|
77
77
|
}
|
|
78
|
-
} catch
|
|
78
|
+
} catch {
|
|
79
79
|
// Return the pattern as is on error.
|
|
80
80
|
}
|
|
81
81
|
return pattern;
|
|
@@ -83,25 +83,25 @@ function parseFoldersToGlobs(patterns, extensions = []) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
87
86
|
* @param {string} _ key, but unused
|
|
88
|
-
* @param {
|
|
87
|
+
* @param {EXPECTED_ANY} value value
|
|
88
|
+
* @returns {{ [x: string]: EXPECTED_ANY }} result
|
|
89
89
|
*/
|
|
90
90
|
const jsonStringifyReplacerSortKeys = (_, value) => {
|
|
91
91
|
/**
|
|
92
|
-
* @param {{ [x: string]:
|
|
93
|
-
* @param {string | number} key
|
|
92
|
+
* @param {{ [x: string]: EXPECTED_ANY }} sorted sorted
|
|
93
|
+
* @param {string | number} key key
|
|
94
|
+
* @returns {{ [x: string]: EXPECTED_ANY }} result
|
|
94
95
|
*/
|
|
95
96
|
const insert = (sorted, key) => {
|
|
96
|
-
// eslint-disable-next-line no-param-reassign
|
|
97
97
|
sorted[key] = value[key];
|
|
98
98
|
return sorted;
|
|
99
99
|
};
|
|
100
|
-
return value instanceof Object && !(value
|
|
100
|
+
return value instanceof Object && !Array.isArray(value) ? Object.keys(value).sort().reduce(insert, {}) : value;
|
|
101
101
|
};
|
|
102
102
|
module.exports = {
|
|
103
103
|
arrify,
|
|
104
|
+
jsonStringifyReplacerSortKeys,
|
|
104
105
|
parseFiles,
|
|
105
|
-
parseFoldersToGlobs
|
|
106
|
-
jsonStringifyReplacerSortKeys
|
|
106
|
+
parseFoldersToGlobs
|
|
107
107
|
};
|
package/dist/worker.js
CHANGED
|
@@ -1,34 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
3
4
|
/** @typedef {import('./getStylelint').Stylelint} Stylelint */
|
|
4
5
|
/** @typedef {import('./getStylelint').LinterOptions} StylelintOptions */
|
|
6
|
+
/** @typedef {import('./getStylelint').LintResult} LintResult */
|
|
5
7
|
/** @typedef {import('./options').Options} Options */
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
setup
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/** @type {Stylelint} */
|
|
13
|
-
let stylelint;
|
|
9
|
+
/** @type {string} */
|
|
10
|
+
let stylelintPath = "stylelint";
|
|
14
11
|
|
|
15
12
|
/** @type {Partial<StylelintOptions>} */
|
|
16
13
|
let linterOptions;
|
|
17
14
|
|
|
15
|
+
/** @type {Promise<Stylelint> | null} */
|
|
16
|
+
let stylelintPromise = null;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Lazily load stylelint on first use
|
|
20
|
+
* @returns {Promise<Stylelint>} stylelint instance
|
|
21
|
+
*/
|
|
22
|
+
async function getStylelint() {
|
|
23
|
+
if (!stylelintPromise) {
|
|
24
|
+
stylelintPromise = (async () => {
|
|
25
|
+
const mod = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(stylelintPath);
|
|
26
|
+
// Handle both CJS (v13-v16) and ESM (v17) exports
|
|
27
|
+
return mod.default || mod;
|
|
28
|
+
})();
|
|
29
|
+
}
|
|
30
|
+
return stylelintPromise;
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
/**
|
|
19
|
-
* @param {Options} options
|
|
20
|
-
* @param {Partial<StylelintOptions>} stylelintOptions
|
|
34
|
+
* @param {Options} options the worker options
|
|
35
|
+
* @param {Partial<StylelintOptions>} stylelintOptions the stylelint options
|
|
21
36
|
*/
|
|
22
37
|
function setup(options, stylelintOptions) {
|
|
23
|
-
|
|
38
|
+
stylelintPath = options.stylelintPath || "stylelint";
|
|
24
39
|
linterOptions = stylelintOptions;
|
|
25
|
-
|
|
40
|
+
// Reset cached stylelint in case path changed
|
|
41
|
+
stylelintPromise = null;
|
|
26
42
|
}
|
|
27
43
|
|
|
28
44
|
/**
|
|
29
|
-
* @param {string | string[]} files
|
|
45
|
+
* @param {string | string[]} files files
|
|
46
|
+
* @returns {Promise<LintResult[]>} results
|
|
30
47
|
*/
|
|
31
48
|
async function lintFiles(files) {
|
|
49
|
+
const stylelint = await getStylelint();
|
|
32
50
|
const {
|
|
33
51
|
results
|
|
34
52
|
} = await stylelint.lint({
|
|
@@ -38,14 +56,16 @@ async function lintFiles(files) {
|
|
|
38
56
|
});
|
|
39
57
|
|
|
40
58
|
// Reset result to work with worker
|
|
41
|
-
return results.map(result => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
return results.map(result => ({
|
|
60
|
+
source: result.source,
|
|
61
|
+
errored: result.errored,
|
|
62
|
+
ignored: result.ignored,
|
|
63
|
+
warnings: result.warnings,
|
|
64
|
+
deprecations: result.deprecations,
|
|
65
|
+
invalidOptionWarnings: result.invalidOptionWarnings,
|
|
66
|
+
parseErrors: result.parseErrors
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
module.exports.getStylelint = getStylelint;
|
|
70
|
+
module.exports.lintFiles = lintFiles;
|
|
71
|
+
module.exports.setup = setup;
|
package/package.json
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-webpack-plugin",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "A Stylelint plugin for webpack",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"stylelint",
|
|
7
|
+
"lint",
|
|
8
|
+
"linter",
|
|
9
|
+
"plugin",
|
|
10
|
+
"webpack"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/webpack/stylelint-webpack-plugin",
|
|
13
|
+
"bugs": "https://github.com/webpack/stylelint-webpack-plugin/issues",
|
|
14
|
+
"repository": "webpack/stylelint-webpack-plugin",
|
|
10
15
|
"funding": {
|
|
11
16
|
"type": "opencollective",
|
|
12
17
|
"url": "https://opencollective.com/webpack"
|
|
13
18
|
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Ricardo Gobbo de Souza <ricardogobbosouza@yahoo.com.br>",
|
|
14
21
|
"main": "dist/index.js",
|
|
15
22
|
"types": "types/index.d.ts",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"types"
|
|
26
|
+
],
|
|
19
27
|
"scripts": {
|
|
20
28
|
"start": "npm run build -- -w",
|
|
21
29
|
"clean": "del-cli dist types",
|
|
@@ -23,32 +31,24 @@
|
|
|
23
31
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write",
|
|
24
32
|
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
|
|
25
33
|
"build": "npm-run-all -p \"build:**\"",
|
|
26
|
-
"commitlint": "commitlint --from=
|
|
34
|
+
"commitlint": "commitlint --from=main",
|
|
27
35
|
"security": "npm audit",
|
|
28
36
|
"lint:prettier": "prettier -w --list-different .",
|
|
29
|
-
"lint:
|
|
37
|
+
"lint:code": "eslint --cache .",
|
|
30
38
|
"lint:spelling": "cspell \"**/*.*\"",
|
|
31
39
|
"lint:types": "tsc --pretty --noEmit",
|
|
32
40
|
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
33
|
-
"fix:
|
|
41
|
+
"fix:code": "npm run lint:code -- --fix",
|
|
34
42
|
"fix:prettier": "npm run lint:prettier -- --write",
|
|
35
|
-
"fix": "npm-run-all -l fix:
|
|
43
|
+
"fix": "npm-run-all -l fix:code fix:prettier",
|
|
36
44
|
"test:only": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest --testTimeout=60000",
|
|
37
45
|
"test:watch": "npm run test:only -- --watch",
|
|
38
46
|
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
|
|
39
47
|
"pretest": "npm run lint",
|
|
40
48
|
"test": "npm run test:coverage",
|
|
41
|
-
"prepare": "husky
|
|
49
|
+
"prepare": "husky && npm run build",
|
|
42
50
|
"release": "standard-version"
|
|
43
51
|
},
|
|
44
|
-
"files": [
|
|
45
|
-
"dist",
|
|
46
|
-
"types"
|
|
47
|
-
],
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"stylelint": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
50
|
-
"webpack": "^5.0.0"
|
|
51
|
-
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"globby": "^11.1.0",
|
|
54
54
|
"jest-worker": "^29.7.0",
|
|
@@ -57,46 +57,53 @@
|
|
|
57
57
|
"schema-utils": "^4.2.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@babel/cli": "^7.
|
|
61
|
-
"@babel/core": "^7.
|
|
62
|
-
"@babel/preset-env": "^7.
|
|
63
|
-
"@commitlint/cli": "^
|
|
64
|
-
"@commitlint/config-conventional": "^
|
|
60
|
+
"@babel/cli": "^7.24.7",
|
|
61
|
+
"@babel/core": "^7.24.7",
|
|
62
|
+
"@babel/preset-env": "^7.24.7",
|
|
63
|
+
"@commitlint/cli": "^19.3.0",
|
|
64
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
65
|
+
"@eslint/js": "^9.32.0",
|
|
66
|
+
"@eslint/markdown": "^7.0.0",
|
|
67
|
+
"@stylistic/eslint-plugin": "^5.2.2",
|
|
65
68
|
"@types/file-entry-cache": "^5.0.4",
|
|
66
69
|
"@types/fs-extra": "^11.0.4",
|
|
67
|
-
"@types/micromatch": "^4.0.
|
|
68
|
-
"@types/node": "^20.
|
|
70
|
+
"@types/micromatch": "^4.0.9",
|
|
71
|
+
"@types/node": "^20.14.9",
|
|
69
72
|
"@types/normalize-path": "^3.0.2",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"babel-eslint": "^10.1.0",
|
|
73
|
-
"babel-jest": "^29.7.0",
|
|
74
|
-
"chokidar": "^3.5.3",
|
|
73
|
+
"babel-jest": "^30.0.0",
|
|
74
|
+
"chokidar": "^3.6.0",
|
|
75
75
|
"cross-env": "^7.0.3",
|
|
76
|
-
"cspell": "^8.
|
|
76
|
+
"cspell": "^8.10.0",
|
|
77
77
|
"del": "^7.1.0",
|
|
78
78
|
"del-cli": "^5.1.0",
|
|
79
|
-
"eslint": "^
|
|
80
|
-
"eslint-config-prettier": "^
|
|
81
|
-
"eslint-
|
|
79
|
+
"eslint": "^9.32.0",
|
|
80
|
+
"eslint-config-prettier": "^10.1.8",
|
|
81
|
+
"eslint-config-webpack": "^4.4.2",
|
|
82
|
+
"eslint-plugin-import": "^2.32.0",
|
|
83
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
84
|
+
"eslint-plugin-jsdoc": "^52.0.0",
|
|
85
|
+
"eslint-plugin-n": "^17.21.0",
|
|
86
|
+
"eslint-plugin-prettier": "^5.5.3",
|
|
87
|
+
"eslint-plugin-unicorn": "^60.0.0",
|
|
82
88
|
"file-loader": "^6.2.0",
|
|
83
89
|
"fs-extra": "^11.2.0",
|
|
84
|
-
"husky": "^
|
|
85
|
-
"jest": "^
|
|
86
|
-
"lint-staged": "^15.2.
|
|
90
|
+
"husky": "^9.1.3",
|
|
91
|
+
"jest": "^30.0.0",
|
|
92
|
+
"lint-staged": "^15.2.7",
|
|
87
93
|
"npm-run-all": "^4.1.5",
|
|
88
94
|
"postcss-scss": "^4.0.9",
|
|
89
|
-
"prettier": "^3.2
|
|
95
|
+
"prettier": "^3.3.2",
|
|
90
96
|
"standard-version": "^9.5.0",
|
|
91
|
-
"stylelint": "^
|
|
92
|
-
"typescript": "^5.
|
|
93
|
-
"
|
|
97
|
+
"stylelint": "^17.1.0",
|
|
98
|
+
"typescript": "^5.5.3",
|
|
99
|
+
"typescript-eslint": "^8.38.0",
|
|
100
|
+
"webpack": "^5.92.1"
|
|
94
101
|
},
|
|
95
|
-
"
|
|
96
|
-
"stylelint",
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"stylelint": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
|
|
104
|
+
"webpack": "^5.0.0"
|
|
105
|
+
},
|
|
106
|
+
"engines": {
|
|
107
|
+
"node": ">= 18.12.0"
|
|
108
|
+
}
|
|
102
109
|
}
|
package/types/getStylelint.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export = getStylelint;
|
|
2
2
|
/**
|
|
3
|
-
* @param {string|undefined} key
|
|
4
|
-
* @param {Options} options
|
|
5
|
-
* @returns {Linter}
|
|
3
|
+
* @param {string|undefined} key a cache key
|
|
4
|
+
* @param {Options} options options
|
|
5
|
+
* @returns {Linter} linter
|
|
6
6
|
*/
|
|
7
7
|
declare function getStylelint(
|
|
8
8
|
key: string | undefined,
|
|
@@ -16,6 +16,7 @@ declare namespace getStylelint {
|
|
|
16
16
|
LinterResult,
|
|
17
17
|
Formatter,
|
|
18
18
|
FormatterType,
|
|
19
|
+
RuleMeta,
|
|
19
20
|
Options,
|
|
20
21
|
AsyncTask,
|
|
21
22
|
LintTask,
|
|
@@ -23,27 +24,28 @@ declare namespace getStylelint {
|
|
|
23
24
|
Worker,
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
type Options = import('./options').Options;
|
|
27
|
-
type Linter = {
|
|
28
|
-
stylelint: Stylelint;
|
|
29
|
-
lintFiles: LintTask;
|
|
30
|
-
cleanup: AsyncTask;
|
|
31
|
-
threads: number;
|
|
32
|
-
};
|
|
33
27
|
type Stylelint = {
|
|
34
28
|
lint: (options: LinterOptions) => Promise<LinterResult>;
|
|
35
29
|
formatters: {
|
|
36
|
-
[k: string]:
|
|
30
|
+
[k: string]: Formatter;
|
|
37
31
|
};
|
|
38
32
|
};
|
|
39
|
-
type LintResult = import(
|
|
40
|
-
type LinterOptions = import(
|
|
41
|
-
type LinterResult = import(
|
|
42
|
-
type Formatter = import(
|
|
43
|
-
type FormatterType = import(
|
|
33
|
+
type LintResult = import("stylelint").LintResult;
|
|
34
|
+
type LinterOptions = import("stylelint").LinterOptions;
|
|
35
|
+
type LinterResult = import("stylelint").LinterResult;
|
|
36
|
+
type Formatter = import("stylelint").Formatter;
|
|
37
|
+
type FormatterType = import("stylelint").FormatterType;
|
|
38
|
+
type RuleMeta = import("stylelint").RuleMeta;
|
|
39
|
+
type Options = import("./options").Options;
|
|
44
40
|
type AsyncTask = () => Promise<void>;
|
|
45
41
|
type LintTask = (files: string | string[]) => Promise<LintResult[]>;
|
|
42
|
+
type Linter = {
|
|
43
|
+
getStylelint: () => Promise<Stylelint>;
|
|
44
|
+
lintFiles: LintTask;
|
|
45
|
+
cleanup: AsyncTask;
|
|
46
|
+
threads: number;
|
|
47
|
+
};
|
|
46
48
|
type Worker = JestWorker & {
|
|
47
49
|
lintFiles: LintTask;
|
|
48
50
|
};
|
|
49
|
-
import { Worker as JestWorker } from
|
|
51
|
+
import { Worker as JestWorker } from "jest-worker";
|
package/types/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export = StylelintWebpackPlugin;
|
|
2
2
|
declare class StylelintWebpackPlugin {
|
|
3
3
|
/**
|
|
4
|
-
* @param {Options} options
|
|
4
|
+
* @param {Options=} options options
|
|
5
5
|
*/
|
|
6
|
-
constructor(options?: Options);
|
|
6
|
+
constructor(options?: Options | undefined);
|
|
7
7
|
key: string;
|
|
8
|
-
options: Partial<import(
|
|
8
|
+
options: Partial<import("./options").PluginOptions>;
|
|
9
9
|
/**
|
|
10
|
-
* @param {Compiler} compiler
|
|
11
|
-
* @param {Options} options
|
|
12
|
-
* @param {string[]} wanted
|
|
13
|
-
* @param {string[]} exclude
|
|
10
|
+
* @param {Compiler} compiler compiler
|
|
11
|
+
* @param {Options} options options
|
|
12
|
+
* @param {string[]} wanted wanted files
|
|
13
|
+
* @param {string[]} exclude exclude files
|
|
14
14
|
*/
|
|
15
15
|
run(
|
|
16
16
|
compiler: Compiler,
|
|
@@ -21,23 +21,22 @@ declare class StylelintWebpackPlugin {
|
|
|
21
21
|
startTime: number;
|
|
22
22
|
prevTimestamps: Map<any, any>;
|
|
23
23
|
/**
|
|
24
|
-
* @param {Compiler} compiler
|
|
24
|
+
* @param {Compiler} compiler compiler
|
|
25
25
|
* @returns {void}
|
|
26
26
|
*/
|
|
27
27
|
apply(compiler: Compiler): void;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
* @returns {string}
|
|
29
|
+
* @param {Compiler} compiler compiler
|
|
30
|
+
* @returns {string} context
|
|
32
31
|
*/
|
|
33
32
|
getContext(compiler: Compiler): string;
|
|
34
33
|
}
|
|
35
34
|
declare namespace StylelintWebpackPlugin {
|
|
36
35
|
export { Compiler, Module, Options, FileSystemInfoEntry };
|
|
37
36
|
}
|
|
38
|
-
type Compiler = import(
|
|
39
|
-
type Module = import(
|
|
40
|
-
type Options = import(
|
|
37
|
+
type Compiler = import("webpack").Compiler;
|
|
38
|
+
type Module = import("webpack").Module;
|
|
39
|
+
type Options = import("./options").Options;
|
|
41
40
|
type FileSystemInfoEntry = Partial<
|
|
42
41
|
| {
|
|
43
42
|
timestamp: number;
|
package/types/linter.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export = linter;
|
|
2
2
|
/**
|
|
3
|
-
* @param {string|undefined} key
|
|
4
|
-
* @param {Options} options
|
|
5
|
-
* @param {Compilation} compilation
|
|
6
|
-
* @returns {{lint: Linter, report: Reporter, threads: number}}
|
|
3
|
+
* @param {string | undefined} key a cache key
|
|
4
|
+
* @param {Options} options options
|
|
5
|
+
* @param {Compilation} compilation compilation
|
|
6
|
+
* @returns {{ lint: Linter, report: Reporter, threads: number }} the linter with additional functions
|
|
7
7
|
*/
|
|
8
8
|
declare function linter(
|
|
9
9
|
key: string | undefined,
|
|
@@ -23,6 +23,7 @@ declare namespace linter {
|
|
|
23
23
|
LinterResult,
|
|
24
24
|
Formatter,
|
|
25
25
|
FormatterType,
|
|
26
|
+
RuleMeta,
|
|
26
27
|
Options,
|
|
27
28
|
GenerateReport,
|
|
28
29
|
Report,
|
|
@@ -31,23 +32,24 @@ declare namespace linter {
|
|
|
31
32
|
LintResultMap,
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
type
|
|
35
|
-
type Compilation = import(
|
|
36
|
-
type
|
|
37
|
-
type
|
|
38
|
-
type
|
|
39
|
-
type
|
|
40
|
-
type
|
|
41
|
-
type
|
|
42
|
-
type
|
|
43
|
-
type FormatterType = import('./getStylelint').FormatterType;
|
|
35
|
+
type Compiler = import("webpack").Compiler;
|
|
36
|
+
type Compilation = import("webpack").Compilation;
|
|
37
|
+
type Stylelint = import("./getStylelint").Stylelint;
|
|
38
|
+
type LintResult = import("./getStylelint").LintResult;
|
|
39
|
+
type LinterResult = import("./getStylelint").LinterResult;
|
|
40
|
+
type Formatter = import("./getStylelint").Formatter;
|
|
41
|
+
type FormatterType = import("./getStylelint").FormatterType;
|
|
42
|
+
type RuleMeta = import("./getStylelint").RuleMeta;
|
|
43
|
+
type Options = import("./options").Options;
|
|
44
44
|
type GenerateReport = (compilation: Compilation) => Promise<void>;
|
|
45
45
|
type Report = {
|
|
46
46
|
errors?: StylelintError;
|
|
47
47
|
warnings?: StylelintError;
|
|
48
48
|
generateReportAsset?: GenerateReport;
|
|
49
49
|
};
|
|
50
|
+
type Reporter = () => Promise<Report>;
|
|
51
|
+
type Linter = (files: string | string[]) => void;
|
|
50
52
|
type LintResultMap = {
|
|
51
|
-
[files: string]:
|
|
53
|
+
[files: string]: LintResult;
|
|
52
54
|
};
|
|
53
|
-
import StylelintError = require(
|
|
55
|
+
import StylelintError = require("./StylelintError");
|