Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add stylelint v15 #323

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [14.x, 16.x, 18.x, 19.x]
stylelint-version: [13.x, 14.x]
stylelint-version: [13.x, 14.x, 15.x]
webpack-version: [latest]

runs-on: ${{ matrix.os }}
Expand Down
2,024 changes: 1,028 additions & 996 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"types"
],
"peerDependencies": {
"stylelint": "^13.0.0 || ^14.0.0",
"stylelint": "^13.0.0 || ^14.0.0 || ^15.0.0",
"webpack": "^5.0.0"
},
"dependencies": {
"globby": "^11.1.0",
"jest-worker": "^29.4.1",
"jest-worker": "^29.4.2",
"micromatch": "^4.0.5",
"normalize-path": "^3.0.0",
"schema-utils": "^4.0.0"
Expand All @@ -62,30 +62,30 @@
"@types/file-entry-cache": "^5.0.2",
"@types/fs-extra": "^9.0.13",
"@types/micromatch": "^4.0.2",
"@types/node": "^18.11.18",
"@types/node": "^18.13.0",
"@types/normalize-path": "^3.0.0",
"@types/webpack": "^5.28.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^29.4.1",
"babel-jest": "^29.4.2",
"chokidar": "^3.5.3",
"cross-env": "^7.0.3",
"cspell": "^6.20.1",
"cspell": "^6.22.0",
"del": "^6.1.1",
"del-cli": "^4.0.1",
"eslint": "^8.33.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-import": "^2.27.5",
"file-loader": "^6.2.0",
"fs-extra": "^10.1.0",
"husky": "^8.0.3",
"jest": "^29.4.1",
"lint-staged": "^13.1.0",
"jest": "^29.4.2",
"lint-staged": "^13.1.1",
"npm-run-all": "^4.1.5",
"postcss-scss": "^4.0.6",
"prettier": "^2.8.3",
"prettier": "^2.8.4",
"standard-version": "^9.5.0",
"stylelint": "^14.16.1",
"stylelint": "^15.0.0",
"typescript": "^4.9.5",
"webpack": "^5.75.0"
},
Expand Down
6 changes: 5 additions & 1 deletion src/getStylelint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ const { getStylelintOptions } = require('./options');
/** @type {{[key: string]: any}} */
const cache = {};

/** @typedef {import('stylelint')} Stylelint */
/** @typedef {{lint: (options: LinterOptions) => Promise<LinterResult>, formatters: { [k: string]: Formatter }}} Stylelint */
/** @typedef {import('stylelint').LintResult} LintResult */
/** @typedef {import('stylelint').LinterOptions} LinterOptions */
/** @typedef {import('stylelint').LinterResult} LinterResult */
/** @typedef {import('stylelint').Formatter} Formatter */
/** @typedef {import('stylelint').FormatterType} FormatterType */
/** @typedef {import('./options').Options} Options */
/** @typedef {(stylelint: Stylelint, filePath: string) => Promise<boolean>} isPathIgnored */
/** @typedef {() => Promise<void>} AsyncTask */
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class StylelintWebpackPlugin {
}

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

/** @type {import('./linter').Linter} */
Expand Down
12 changes: 6 additions & 6 deletions src/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const StylelintError = require('./StylelintError');
const getStylelint = require('./getStylelint');
const { arrify } = require('./utils');

/** @typedef {import('stylelint')} Stylelint */
/** @typedef {import('stylelint').LintResult} LintResult */
/** @typedef {import('stylelint').LinterResult} LinterResult */
/** @typedef {import('stylelint').Formatter} Formatter */
/** @typedef {import('stylelint').FormatterType} FormatterType */
/** @typedef {import('webpack').Compiler} Compiler */
/** @typedef {import('webpack').Compilation} Compilation */
/** @typedef {import('./options').Options} Options */
/** @typedef {import('./getStylelint').Stylelint} Stylelint */
/** @typedef {import('./getStylelint').LintResult} LintResult */
/** @typedef {import('./getStylelint').LinterResult} LinterResult */
/** @typedef {import('./getStylelint').Formatter} Formatter */
/** @typedef {import('./getStylelint').FormatterType} FormatterType */
/** @typedef {import('./getStylelint').isPathIgnored} isPathIgnored */
/** @typedef {import('./options').Options} Options */
/** @typedef {(compilation: Compilation) => Promise<void>} GenerateReport */
/** @typedef {{errors?: StylelintError, warnings?: StylelintError, generateReportAsset?: GenerateReport}} Report */
/** @typedef {() => Promise<Report>} Reporter */
Expand Down
5 changes: 2 additions & 3 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ const { validate } = require('schema-utils');

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

/** @typedef {import("stylelint")} stylelint */
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
/** @typedef {import("stylelint").FormatterType} FormatterType */
/** @typedef {import('./getStylelint').LinterOptions} StylelintOptions */
/** @typedef {import('./getStylelint').FormatterType} FormatterType */

/**
* @typedef {Object} OutputReport
Expand Down
4 changes: 2 additions & 2 deletions src/worker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @typedef {import('stylelint')} Stylelint */
/** @typedef {import("stylelint").LinterOptions} StylelintOptions */
/** @typedef {import('./getStylelint').Stylelint} Stylelint */
/** @typedef {import('./getStylelint').LinterOptions} StylelintOptions */
/** @typedef {import('./options').Options} Options */

Object.assign(module.exports, {
Expand Down
1 change: 0 additions & 1 deletion test/fail-on-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('fail on config', () => {
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
expect(errors).toHaveLength(1);
expect(errors[0].message).toMatch(/Map keys must be unique/);
done();
});
});
Expand Down
66 changes: 10 additions & 56 deletions types/getStylelint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ declare namespace getStylelint {
export {
Stylelint,
LintResult,
LinterOptions,
LinterResult,
Formatter,
FormatterType,
Options,
isPathIgnored,
AsyncTask,
Expand All @@ -29,67 +33,17 @@ type Linter = {
cleanup: AsyncTask;
threads: number;
};
type Stylelint = import('postcss').PluginCreator<
import('stylelint').PostcssPluginOptions
> & {
lint: (
options: import('stylelint').LinterOptions
) => Promise<import('stylelint').LinterResult>;
rules: {
[k: string]: import('stylelint').Rule<any, any>;
};
type Stylelint = {
lint: (options: LinterOptions) => Promise<LinterResult>;
formatters: {
[k: string]: import('stylelint').Formatter;
};
createPlugin: (
ruleName: string,
rule: import('stylelint').Rule<any, any>
) => {
ruleName: string;
rule: import('stylelint').Rule<any, any>;
};
createLinter: (
options: import('stylelint').LinterOptions
) => import('stylelint').InternalApi;
resolveConfig: (
filePath: string,
options?:
| Pick<
import('stylelint').LinterOptions,
'cwd' | 'config' | 'configFile' | 'configBasedir'
>
| undefined
) => Promise<import('stylelint').Config | undefined>;
utils: {
report: (problem: import('stylelint').Problem) => void;
ruleMessages: <
T extends import('stylelint').RuleMessages,
R extends { [K in keyof T]: T[K] }
>(
ruleName: string,
messages: T
) => R;
validateOptions: (
result: import('stylelint').PostcssResult,
ruleName: string,
...optionDescriptions: import('stylelint').RuleOptions[]
) => boolean;
checkAgainstRule: <T_1, O extends Object>(
options: {
ruleName: string;
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
root: import('postcss').Root;
result?: import('stylelint').PostcssResult | undefined;
context?: import('stylelint').RuleContext | undefined;
},
callback: (warning: import('postcss').Warning) => void
) => void;
};
reference: {
longhandSubPropertiesOfShorthandProperties: import('stylelint').LonghandSubPropertiesOfShorthandProperties;
};
};
type LintResult = import('stylelint').LintResult;
type LinterOptions = import('stylelint').LinterOptions;
type LinterResult = import('stylelint').LinterResult;
type Formatter = import('stylelint').Formatter;
type FormatterType = import('stylelint').FormatterType;
type isPathIgnored = (
stylelint: Stylelint,
filePath: string
Expand Down
75 changes: 8 additions & 67 deletions types/linter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ declare function linter(
};
declare namespace linter {
export {
Compiler,
Compilation,
Stylelint,
LintResult,
LinterResult,
Formatter,
FormatterType,
Compiler,
Compilation,
Options,
isPathIgnored,
Options,
GenerateReport,
Report,
Reporter,
Expand All @@ -37,74 +37,15 @@ declare namespace linter {
}
type Options = import('./options').Options;
type Compilation = import('webpack').Compilation;
type Stylelint = import('postcss').PluginCreator<
import('stylelint').PostcssPluginOptions
> & {
lint: (
options: import('stylelint').LinterOptions
) => Promise<import('stylelint').LinterResult>;
rules: {
[k: string]: import('stylelint').Rule<any, any>;
};
formatters: {
[k: string]: import('stylelint').Formatter;
};
createPlugin: (
ruleName: string,
rule: import('stylelint').Rule<any, any>
) => {
ruleName: string;
rule: import('stylelint').Rule<any, any>;
};
createLinter: (
options: import('stylelint').LinterOptions
) => import('stylelint').InternalApi;
resolveConfig: (
filePath: string,
options?:
| Pick<
import('stylelint').LinterOptions,
'cwd' | 'config' | 'configFile' | 'configBasedir'
>
| undefined
) => Promise<import('stylelint').Config | undefined>;
utils: {
report: (problem: import('stylelint').Problem) => void;
ruleMessages: <
T extends import('stylelint').RuleMessages,
R extends { [K in keyof T]: T[K] }
>(
ruleName: string,
messages: T
) => R;
validateOptions: (
result: import('stylelint').PostcssResult,
ruleName: string,
...optionDescriptions: import('stylelint').RuleOptions[]
) => boolean;
checkAgainstRule: <T_1, O extends Object>(
options: {
ruleName: string;
ruleSettings: import('stylelint').ConfigRuleSettings<T_1, O>;
root: import('postcss').Root;
result?: import('stylelint').PostcssResult | undefined;
context?: import('stylelint').RuleContext | undefined;
},
callback: (warning: import('postcss').Warning) => void
) => void;
};
reference: {
longhandSubPropertiesOfShorthandProperties: import('stylelint').LonghandSubPropertiesOfShorthandProperties;
};
};
type Stylelint = import('./getStylelint').Stylelint;
type Linter = (files: string | string[]) => void;
type Reporter = () => Promise<Report>;
import getStylelint = require('./getStylelint');
type LintResult = import('stylelint').LintResult;
type LinterResult = import('stylelint').LinterResult;
type Formatter = import('stylelint').Formatter;
type FormatterType = import('stylelint').FormatterType;
type Compiler = import('webpack').Compiler;
type LintResult = import('./getStylelint').LintResult;
type LinterResult = import('./getStylelint').LinterResult;
type Formatter = import('./getStylelint').Formatter;
type FormatterType = import('./getStylelint').FormatterType;
type isPathIgnored = import('./getStylelint').isPathIgnored;
type GenerateReport = (compilation: Compilation) => Promise<void>;
type Report = {
Expand Down
Loading