Skip to content

Commit c0a11a9

Browse files
feat: support stylelint v14 for webpack 4 (#251)
* feat: support stylelint v14 * ci: update branch * ci: fix exclude option * ci: disable security audit * ci: fix stylelint version
1 parent aa533ab commit c0a11a9

File tree

13 files changed

+3412
-7405
lines changed

13 files changed

+3412
-7405
lines changed

.github/workflows/nodejs.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ jobs:
5353
strategy:
5454
matrix:
5555
os: [ubuntu-latest, windows-latest, macos-latest]
56-
node-version: [10.x, 12.x, 14.x]
56+
node-version: [10.x, 12.x, 14.x, 16.x]
57+
stylelint-version: [13.x, 14.x]
5758
webpack-version: [4, latest]
59+
exclude:
60+
- node-version: 10.x
61+
stylelint-version: 14.x
5862

5963
runs-on: ${{ matrix.os }}
6064

@@ -84,6 +88,9 @@ jobs:
8488
- name: Install webpack ${{ matrix.webpack-version }}
8589
run: npm i webpack@${{ matrix.webpack-version }}
8690

91+
- name: Install stylelint ${{ matrix.stylelint-version }}
92+
run: npm i stylelint@${{ matrix.stylelint-version }}
93+
8794
- name: Run tests for webpack version ${{ matrix.webpack-version }}
8895
run: npm run test:coverage -- --ci
8996

declarations/getStylelint.d.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="stylelint" />
12
/**
23
* @param {string|undefined} key
34
* @param {Options} options
@@ -7,7 +8,54 @@ export default function getStylelint(
78
key: string | undefined,
89
{ threads, ...options }: Options
910
): Linter;
10-
export type Stylelint = typeof import('stylelint');
11+
export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
12+
import('stylelint').PostcssPluginOptions
13+
> & {
14+
lint: (
15+
options: import('stylelint').LinterOptions
16+
) => Promise<import('stylelint').LinterResult>;
17+
rules: {
18+
[k: string]: import('stylelint').Rule<any, any>;
19+
};
20+
formatters: {
21+
[k: string]: import('stylelint').Formatter;
22+
};
23+
createPlugin: (
24+
ruleName: string,
25+
plugin: import('stylelint').Plugin<any, any>
26+
) => {
27+
ruleName: string;
28+
rule: import('stylelint').Rule<any, any>;
29+
};
30+
createLinter: (
31+
options: import('stylelint').LinterOptions
32+
) => import('stylelint').InternalApi;
33+
utils: {
34+
report: (problem: import('stylelint').Problem) => void;
35+
ruleMessages: <
36+
T extends import('stylelint').RuleMessages,
37+
R extends { [K in keyof T]: T[K] }
38+
>(
39+
ruleName: string,
40+
messages: T
41+
) => R;
42+
validateOptions: (
43+
result: import('stylelint').PostcssResult,
44+
ruleName: string,
45+
...optionDescriptions: import('stylelint').RuleOptions[]
46+
) => boolean;
47+
checkAgainstRule: <T_1, O extends Object>(
48+
options: {
49+
ruleName: string;
50+
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
51+
root: import('stylelint/node_modules/postcss').Root;
52+
},
53+
callback: (
54+
warning: import('stylelint/node_modules/postcss').Warning
55+
) => void
56+
) => void;
57+
};
58+
};
1159
export type LintResult = import('stylelint').LintResult;
1260
export type Options = import('./options').Options;
1361
export type AsyncTask = () => Promise<void>;

declarations/index.d.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ declare class StylelintWebpackPlugin {
2020
*/
2121
run(compiler: Compiler): Promise<void>;
2222
startTime: number;
23-
prevTimestamps: Map<any, any>;
23+
/** @type {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} */
24+
prevTimestamps: ReadonlyMap<
25+
string,
26+
'ignore' | FileSystemInfoEntry | null | undefined
27+
>;
2428
/**
2529
* @param {Compiler} compiler
2630
* @returns {void}
@@ -40,10 +44,13 @@ declare class StylelintWebpackPlugin {
4044
*/
4145
getFiles(compiler: Compiler, wanted: string[], exclude: string[]): string[];
4246
/**
43-
* @param {Map<string, null | FileSystemInfoEntry | "ignore">} fileTimestamps
47+
* @param {ReadonlyMap<string, null | FileSystemInfoEntry | "ignore" | undefined>} fileTimestamps
4448
* @returns {string[]}
4549
*/
4650
getChangedFiles(
47-
fileTimestamps: Map<string, 'ignore' | FileSystemInfoEntry | null>
51+
fileTimestamps: ReadonlyMap<
52+
string,
53+
'ignore' | FileSystemInfoEntry | null | undefined
54+
>
4855
): string[];
4956
}

declarations/linter.d.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="stylelint" />
12
/**
23
* @param {string|undefined} key
34
* @param {Options} options
@@ -13,7 +14,54 @@ export default function linter(
1314
report: Reporter;
1415
threads: number;
1516
};
16-
export type Stylelint = typeof import('stylelint');
17+
export type Stylelint = import('stylelint/node_modules/postcss').PluginCreator<
18+
import('stylelint').PostcssPluginOptions
19+
> & {
20+
lint: (
21+
options: import('stylelint').LinterOptions
22+
) => Promise<import('stylelint').LinterResult>;
23+
rules: {
24+
[k: string]: import('stylelint').Rule<any, any>;
25+
};
26+
formatters: {
27+
[k: string]: import('stylelint').Formatter;
28+
};
29+
createPlugin: (
30+
ruleName: string,
31+
plugin: import('stylelint').Plugin<any, any>
32+
) => {
33+
ruleName: string;
34+
rule: import('stylelint').Rule<any, any>;
35+
};
36+
createLinter: (
37+
options: import('stylelint').LinterOptions
38+
) => import('stylelint').InternalApi;
39+
utils: {
40+
report: (problem: import('stylelint').Problem) => void;
41+
ruleMessages: <
42+
T extends import('stylelint').RuleMessages,
43+
R extends { [K in keyof T]: T[K] }
44+
>(
45+
ruleName: string,
46+
messages: T
47+
) => R;
48+
validateOptions: (
49+
result: import('stylelint').PostcssResult,
50+
ruleName: string,
51+
...optionDescriptions: import('stylelint').RuleOptions[]
52+
) => boolean;
53+
checkAgainstRule: <T_1, O extends Object>(
54+
options: {
55+
ruleName: string;
56+
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
57+
root: import('stylelint/node_modules/postcss').Root;
58+
},
59+
callback: (
60+
warning: import('stylelint/node_modules/postcss').Warning
61+
) => void
62+
) => void;
63+
};
64+
};
1765
export type LintResult = import('stylelint').LintResult;
1866
export type Compiler = import('webpack').Compiler;
1967
export type Compilation = import('webpack').Compilation;

declarations/options.d.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="stylelint" />
12
/** @typedef {import("stylelint")} stylelint */
23
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
34
/** @typedef {import("stylelint").FormatterType} FormatterType */
@@ -36,7 +37,54 @@ export function getOptions(pluginOptions: Options): Partial<PluginOptions>;
3637
export function getStylelintOptions(
3738
pluginOptions: Options
3839
): Partial<StylelintOptions>;
39-
export type stylelint = typeof import('stylelint');
40+
export type stylelint = import('stylelint/node_modules/postcss').PluginCreator<
41+
import('stylelint').PostcssPluginOptions
42+
> & {
43+
lint: (
44+
options: import('stylelint').LinterOptions
45+
) => Promise<import('stylelint').LinterResult>;
46+
rules: {
47+
[k: string]: import('stylelint').Rule<any, any>;
48+
};
49+
formatters: {
50+
[k: string]: import('stylelint').Formatter;
51+
};
52+
createPlugin: (
53+
ruleName: string,
54+
plugin: import('stylelint').Plugin<any, any>
55+
) => {
56+
ruleName: string;
57+
rule: import('stylelint').Rule<any, any>;
58+
};
59+
createLinter: (
60+
options: import('stylelint').LinterOptions
61+
) => import('stylelint').InternalApi;
62+
utils: {
63+
report: (problem: import('stylelint').Problem) => void;
64+
ruleMessages: <
65+
T extends import('stylelint').RuleMessages,
66+
R extends { [K in keyof T]: T[K] }
67+
>(
68+
ruleName: string,
69+
messages: T
70+
) => R;
71+
validateOptions: (
72+
result: import('stylelint').PostcssResult,
73+
ruleName: string,
74+
...optionDescriptions: import('stylelint').RuleOptions[]
75+
) => boolean;
76+
checkAgainstRule: <T_1, O extends Object>(
77+
options: {
78+
ruleName: string;
79+
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
80+
root: import('stylelint/node_modules/postcss').Root;
81+
},
82+
callback: (
83+
warning: import('stylelint/node_modules/postcss').Warning
84+
) => void
85+
) => void;
86+
};
87+
};
4088
export type StylelintOptions = import('stylelint').LinterOptions;
4189
export type FormatterType = import('stylelint').FormatterType;
4290
export type OutputReport = {

declarations/worker.d.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1-
export type Stylelint = typeof import('stylelint');
1+
/// <reference types="stylelint" />
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+
};
250
export type StylelintOptions = import('stylelint').LinterOptions;
351
export type Options = import('./options').Options;

0 commit comments

Comments
 (0)