Skip to content

Commit 8dc5881

Browse files
feat: add stylelint v15 (#323)
1 parent d9a850e commit 8dc5881

13 files changed

+1079
-1272
lines changed

.github/workflows/nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
matrix:
6262
os: [ubuntu-latest, windows-latest, macos-latest]
6363
node-version: [14.x, 16.x, 18.x, 19.x]
64-
stylelint-version: [13.x, 14.x]
64+
stylelint-version: [13.x, 14.x, 15.x]
6565
webpack-version: [latest]
6666

6767
runs-on: ${{ matrix.os }}

package-lock.json

+1,028-996
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
"types"
4444
],
4545
"peerDependencies": {
46-
"stylelint": "^13.0.0 || ^14.0.0",
46+
"stylelint": "^13.0.0 || ^14.0.0 || ^15.0.0",
4747
"webpack": "^5.0.0"
4848
},
4949
"dependencies": {
5050
"globby": "^11.1.0",
51-
"jest-worker": "^29.4.1",
51+
"jest-worker": "^29.4.2",
5252
"micromatch": "^4.0.5",
5353
"normalize-path": "^3.0.0",
5454
"schema-utils": "^4.0.0"
@@ -62,30 +62,30 @@
6262
"@types/file-entry-cache": "^5.0.2",
6363
"@types/fs-extra": "^9.0.13",
6464
"@types/micromatch": "^4.0.2",
65-
"@types/node": "^18.11.18",
65+
"@types/node": "^18.13.0",
6666
"@types/normalize-path": "^3.0.0",
6767
"@types/webpack": "^5.28.0",
6868
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
6969
"babel-eslint": "^10.1.0",
70-
"babel-jest": "^29.4.1",
70+
"babel-jest": "^29.4.2",
7171
"chokidar": "^3.5.3",
7272
"cross-env": "^7.0.3",
73-
"cspell": "^6.20.1",
73+
"cspell": "^6.22.0",
7474
"del": "^6.1.1",
7575
"del-cli": "^4.0.1",
76-
"eslint": "^8.33.0",
76+
"eslint": "^8.34.0",
7777
"eslint-config-prettier": "^8.6.0",
7878
"eslint-plugin-import": "^2.27.5",
7979
"file-loader": "^6.2.0",
8080
"fs-extra": "^10.1.0",
8181
"husky": "^8.0.3",
82-
"jest": "^29.4.1",
83-
"lint-staged": "^13.1.0",
82+
"jest": "^29.4.2",
83+
"lint-staged": "^13.1.1",
8484
"npm-run-all": "^4.1.5",
8585
"postcss-scss": "^4.0.6",
86-
"prettier": "^2.8.3",
86+
"prettier": "^2.8.4",
8787
"standard-version": "^9.5.0",
88-
"stylelint": "^14.16.1",
88+
"stylelint": "^15.0.0",
8989
"typescript": "^4.9.5",
9090
"webpack": "^5.75.0"
9191
},

src/getStylelint.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ const { getStylelintOptions } = require('./options');
1010
/** @type {{[key: string]: any}} */
1111
const cache = {};
1212

13-
/** @typedef {import('stylelint')} Stylelint */
13+
/** @typedef {{lint: (options: LinterOptions) => Promise<LinterResult>, formatters: { [k: string]: Formatter }}} Stylelint */
1414
/** @typedef {import('stylelint').LintResult} LintResult */
15+
/** @typedef {import('stylelint').LinterOptions} LinterOptions */
16+
/** @typedef {import('stylelint').LinterResult} LinterResult */
17+
/** @typedef {import('stylelint').Formatter} Formatter */
18+
/** @typedef {import('stylelint').FormatterType} FormatterType */
1519
/** @typedef {import('./options').Options} Options */
1620
/** @typedef {(stylelint: Stylelint, filePath: string) => Promise<boolean>} isPathIgnored */
1721
/** @typedef {() => Promise<void>} AsyncTask */

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class StylelintWebpackPlugin {
9090
}
9191

9292
compiler.hooks.thisCompilation.tap(this.key, (compilation) => {
93-
/** @type {import('stylelint')} */
93+
/** @type {import('./getStylelint').Stylelint} */
9494
let stylelint;
9595

9696
/** @type {import('./linter').Linter} */

src/linter.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const StylelintError = require('./StylelintError');
44
const getStylelint = require('./getStylelint');
55
const { arrify } = require('./utils');
66

7-
/** @typedef {import('stylelint')} Stylelint */
8-
/** @typedef {import('stylelint').LintResult} LintResult */
9-
/** @typedef {import('stylelint').LinterResult} LinterResult */
10-
/** @typedef {import('stylelint').Formatter} Formatter */
11-
/** @typedef {import('stylelint').FormatterType} FormatterType */
127
/** @typedef {import('webpack').Compiler} Compiler */
138
/** @typedef {import('webpack').Compilation} Compilation */
14-
/** @typedef {import('./options').Options} Options */
9+
/** @typedef {import('./getStylelint').Stylelint} Stylelint */
10+
/** @typedef {import('./getStylelint').LintResult} LintResult */
11+
/** @typedef {import('./getStylelint').LinterResult} LinterResult */
12+
/** @typedef {import('./getStylelint').Formatter} Formatter */
13+
/** @typedef {import('./getStylelint').FormatterType} FormatterType */
1514
/** @typedef {import('./getStylelint').isPathIgnored} isPathIgnored */
15+
/** @typedef {import('./options').Options} Options */
1616
/** @typedef {(compilation: Compilation) => Promise<void>} GenerateReport */
1717
/** @typedef {{errors?: StylelintError, warnings?: StylelintError, generateReportAsset?: GenerateReport}} Report */
1818
/** @typedef {() => Promise<Report>} Reporter */

src/options.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ const { validate } = require('schema-utils');
22

33
const schema = require('./options.json');
44

5-
/** @typedef {import("stylelint")} stylelint */
6-
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
7-
/** @typedef {import("stylelint").FormatterType} FormatterType */
5+
/** @typedef {import('./getStylelint').LinterOptions} StylelintOptions */
6+
/** @typedef {import('./getStylelint').FormatterType} FormatterType */
87

98
/**
109
* @typedef {Object} OutputReport

src/worker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/** @typedef {import('stylelint')} Stylelint */
2-
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
1+
/** @typedef {import('./getStylelint').Stylelint} Stylelint */
2+
/** @typedef {import('./getStylelint').LinterOptions} StylelintOptions */
33
/** @typedef {import('./options').Options} Options */
44

55
Object.assign(module.exports, {

test/fail-on-config.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ describe('fail on config', () => {
1212
expect(stats.hasWarnings()).toBe(false);
1313
expect(stats.hasErrors()).toBe(true);
1414
expect(errors).toHaveLength(1);
15-
expect(errors[0].message).toMatch(/Map keys must be unique/);
1615
done();
1716
});
1817
});

types/getStylelint.d.ts

+10-56
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ declare namespace getStylelint {
1313
export {
1414
Stylelint,
1515
LintResult,
16+
LinterOptions,
17+
LinterResult,
18+
Formatter,
19+
FormatterType,
1620
Options,
1721
isPathIgnored,
1822
AsyncTask,
@@ -29,67 +33,17 @@ type Linter = {
2933
cleanup: AsyncTask;
3034
threads: number;
3135
};
32-
type Stylelint = import('postcss').PluginCreator<
33-
import('stylelint').PostcssPluginOptions
34-
> & {
35-
lint: (
36-
options: import('stylelint').LinterOptions
37-
) => Promise<import('stylelint').LinterResult>;
38-
rules: {
39-
[k: string]: import('stylelint').Rule<any, any>;
40-
};
36+
type Stylelint = {
37+
lint: (options: LinterOptions) => Promise<LinterResult>;
4138
formatters: {
4239
[k: string]: import('stylelint').Formatter;
4340
};
44-
createPlugin: (
45-
ruleName: string,
46-
rule: import('stylelint').Rule<any, any>
47-
) => {
48-
ruleName: string;
49-
rule: import('stylelint').Rule<any, any>;
50-
};
51-
createLinter: (
52-
options: import('stylelint').LinterOptions
53-
) => import('stylelint').InternalApi;
54-
resolveConfig: (
55-
filePath: string,
56-
options?:
57-
| Pick<
58-
import('stylelint').LinterOptions,
59-
'cwd' | 'config' | 'configFile' | 'configBasedir'
60-
>
61-
| undefined
62-
) => Promise<import('stylelint').Config | undefined>;
63-
utils: {
64-
report: (problem: import('stylelint').Problem) => void;
65-
ruleMessages: <
66-
T extends import('stylelint').RuleMessages,
67-
R extends { [K in keyof T]: T[K] }
68-
>(
69-
ruleName: string,
70-
messages: T
71-
) => R;
72-
validateOptions: (
73-
result: import('stylelint').PostcssResult,
74-
ruleName: string,
75-
...optionDescriptions: import('stylelint').RuleOptions[]
76-
) => boolean;
77-
checkAgainstRule: <T_1, O extends Object>(
78-
options: {
79-
ruleName: string;
80-
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
81-
root: import('postcss').Root;
82-
result?: import('stylelint').PostcssResult | undefined;
83-
context?: import('stylelint').RuleContext | undefined;
84-
},
85-
callback: (warning: import('postcss').Warning) => void
86-
) => void;
87-
};
88-
reference: {
89-
longhandSubPropertiesOfShorthandProperties: import('stylelint').LonghandSubPropertiesOfShorthandProperties;
90-
};
9141
};
9242
type LintResult = import('stylelint').LintResult;
43+
type LinterOptions = import('stylelint').LinterOptions;
44+
type LinterResult = import('stylelint').LinterResult;
45+
type Formatter = import('stylelint').Formatter;
46+
type FormatterType = import('stylelint').FormatterType;
9347
type isPathIgnored = (
9448
stylelint: Stylelint,
9549
filePath: string

types/linter.d.ts

+8-67
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ declare function linter(
1919
};
2020
declare namespace linter {
2121
export {
22+
Compiler,
23+
Compilation,
2224
Stylelint,
2325
LintResult,
2426
LinterResult,
2527
Formatter,
2628
FormatterType,
27-
Compiler,
28-
Compilation,
29-
Options,
3029
isPathIgnored,
30+
Options,
3131
GenerateReport,
3232
Report,
3333
Reporter,
@@ -37,74 +37,15 @@ declare namespace linter {
3737
}
3838
type Options = import('./options').Options;
3939
type Compilation = import('webpack').Compilation;
40-
type Stylelint = import('postcss').PluginCreator<
41-
import('stylelint').PostcssPluginOptions
42-
> & {
43-
lint: (
44-
options: import('stylelint').LinterOptions
45-
) => Promise<import('stylelint').LinterResult>;
46-
rules: {
47-
[k: string]: import('stylelint').Rule<any, any>;
48-
};
49-
formatters: {
50-
[k: string]: import('stylelint').Formatter;
51-
};
52-
createPlugin: (
53-
ruleName: string,
54-
rule: import('stylelint').Rule<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-
resolveConfig: (
63-
filePath: string,
64-
options?:
65-
| Pick<
66-
import('stylelint').LinterOptions,
67-
'cwd' | 'config' | 'configFile' | 'configBasedir'
68-
>
69-
| undefined
70-
) => Promise<import('stylelint').Config | undefined>;
71-
utils: {
72-
report: (problem: import('stylelint').Problem) => void;
73-
ruleMessages: <
74-
T extends import('stylelint').RuleMessages,
75-
R extends { [K in keyof T]: T[K] }
76-
>(
77-
ruleName: string,
78-
messages: T
79-
) => R;
80-
validateOptions: (
81-
result: import('stylelint').PostcssResult,
82-
ruleName: string,
83-
...optionDescriptions: import('stylelint').RuleOptions[]
84-
) => boolean;
85-
checkAgainstRule: <T_1, O extends Object>(
86-
options: {
87-
ruleName: string;
88-
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
89-
root: import('postcss').Root;
90-
result?: import('stylelint').PostcssResult | undefined;
91-
context?: import('stylelint').RuleContext | undefined;
92-
},
93-
callback: (warning: import('postcss').Warning) => void
94-
) => void;
95-
};
96-
reference: {
97-
longhandSubPropertiesOfShorthandProperties: import('stylelint').LonghandSubPropertiesOfShorthandProperties;
98-
};
99-
};
40+
type Stylelint = import('./getStylelint').Stylelint;
10041
type Linter = (files: string | string[]) => void;
10142
type Reporter = () => Promise<Report>;
10243
import getStylelint = require('./getStylelint');
103-
type LintResult = import('stylelint').LintResult;
104-
type LinterResult = import('stylelint').LinterResult;
105-
type Formatter = import('stylelint').Formatter;
106-
type FormatterType = import('stylelint').FormatterType;
10744
type Compiler = import('webpack').Compiler;
45+
type LintResult = import('./getStylelint').LintResult;
46+
type LinterResult = import('./getStylelint').LinterResult;
47+
type Formatter = import('./getStylelint').Formatter;
48+
type FormatterType = import('./getStylelint').FormatterType;
10849
type isPathIgnored = import('./getStylelint').isPathIgnored;
10950
type GenerateReport = (compilation: Compilation) => Promise<void>;
11051
type Report = {

0 commit comments

Comments
 (0)