stylelint-webpack-plugin 2.1.1 → 2.3.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 +42 -5
- package/declarations/StylelintError.d.ts +2 -30
- package/declarations/cjs.d.ts +2 -1
- package/declarations/getStylelint.d.ts +72 -0
- package/declarations/index.d.ts +41 -3
- package/declarations/linter.d.ts +73 -38
- package/declarations/options.d.ts +110 -0
- package/declarations/utils.d.ts +12 -7
- package/declarations/worker.d.ts +51 -0
- package/dist/StylelintError.js +3 -18
- package/dist/getStylelint.js +132 -0
- package/dist/index.js +215 -31
- package/dist/linter.js +246 -80
- package/dist/options.js +95 -0
- package/dist/options.json +38 -4
- package/dist/utils.js +66 -11
- package/dist/worker.js +50 -0
- package/package.json +39 -37
- package/CHANGELOG.md +0 -137
- package/declarations/LintDirtyModulesPlugin.d.ts +0 -64
- package/declarations/getOptions.d.ts +0 -32
- package/dist/LintDirtyModulesPlugin.js +0 -118
- package/dist/getOptions.js +0 -74
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-webpack-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A Stylelint plugin for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/stylelint-webpack-plugin",
|
|
7
|
-
"author": "
|
|
8
|
-
"contributors": [
|
|
9
|
-
"Ricardo Gobbo de Souza <ricardogobbosouza@yahoo.com.br>"
|
|
10
|
-
],
|
|
7
|
+
"author": "Ricardo Gobbo de Souza <ricardogobbosouza@yahoo.com.br>",
|
|
11
8
|
"homepage": "https://github.com/webpack-contrib/stylelint-webpack-plugin",
|
|
12
9
|
"bugs": "https://github.com/webpack-contrib/stylelint-webpack-plugin/issues",
|
|
13
10
|
"funding": {
|
|
@@ -28,62 +25,67 @@
|
|
|
28
25
|
"build": "npm-run-all -p \"build:**\"",
|
|
29
26
|
"commitlint": "commitlint --from=master",
|
|
30
27
|
"security": "npm audit",
|
|
31
|
-
"lint:prettier": "prettier --list-different .",
|
|
28
|
+
"lint:prettier": "prettier -w --list-different .",
|
|
32
29
|
"lint:js": "eslint --cache .",
|
|
33
30
|
"lint:types": "tsc --pretty --noEmit",
|
|
34
31
|
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
35
|
-
"test:only": "cross-env NODE_ENV=test jest",
|
|
32
|
+
"test:only": "cross-env NODE_ENV=test jest --testTimeout=60000",
|
|
36
33
|
"test:watch": "npm run test:only -- --watch",
|
|
37
34
|
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
|
|
38
35
|
"pretest": "npm run lint",
|
|
39
36
|
"test": "npm run test:coverage",
|
|
40
|
-
"prepare": "npm run build",
|
|
41
|
-
"release": "standard-version"
|
|
42
|
-
"defaults": "webpack-defaults"
|
|
37
|
+
"prepare": "husky install && npm run build",
|
|
38
|
+
"release": "standard-version"
|
|
43
39
|
},
|
|
44
40
|
"files": [
|
|
45
41
|
"dist",
|
|
46
42
|
"declarations"
|
|
47
43
|
],
|
|
48
44
|
"peerDependencies": {
|
|
49
|
-
"stylelint": "^13.0.0",
|
|
45
|
+
"stylelint": "^13.0.0 || ^14.0.0",
|
|
50
46
|
"webpack": "^4.0.0 || ^5.0.0"
|
|
51
47
|
},
|
|
52
48
|
"dependencies": {
|
|
49
|
+
"@types/stylelint": "^13.13.3",
|
|
53
50
|
"arrify": "^2.0.1",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
51
|
+
"jest-worker": "^27.3.1",
|
|
52
|
+
"globby": "^11.0.4",
|
|
53
|
+
"micromatch": "^4.0.4",
|
|
54
|
+
"normalize-path": "^3.0.0",
|
|
55
|
+
"schema-utils": "^3.1.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
61
|
-
"@commitlint/cli": "^
|
|
62
|
-
"@commitlint/config-conventional": "^
|
|
63
|
-
"@types/
|
|
64
|
-
"@types/
|
|
65
|
-
"@types/
|
|
66
|
-
"@webpack
|
|
58
|
+
"@babel/cli": "^7.16.0",
|
|
59
|
+
"@babel/core": "^7.16.0",
|
|
60
|
+
"@babel/preset-env": "^7.16.0",
|
|
61
|
+
"@commitlint/cli": "^12.1.4",
|
|
62
|
+
"@commitlint/config-conventional": "^12.1.4",
|
|
63
|
+
"@types/fs-extra": "^9.0.13",
|
|
64
|
+
"@types/micromatch": "^4.0.2",
|
|
65
|
+
"@types/normalize-path": "^3.0.0",
|
|
66
|
+
"@types/webpack": "^5.28.0",
|
|
67
67
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
68
68
|
"babel-eslint": "^10.1.0",
|
|
69
|
-
"babel-jest": "^
|
|
70
|
-
"
|
|
69
|
+
"babel-jest": "^27.3.1",
|
|
70
|
+
"chokidar": "^3.5.2",
|
|
71
|
+
"cross-env": "^7.0.3",
|
|
71
72
|
"del": "^6.0.0",
|
|
72
73
|
"del-cli": "^3.0.1",
|
|
73
|
-
"eslint": "^7.
|
|
74
|
-
"eslint-config-prettier": "^
|
|
75
|
-
"eslint-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"husky": "^
|
|
79
|
-
"jest": "^
|
|
80
|
-
"lint-staged": "^10.4
|
|
74
|
+
"eslint": "^7.32.0",
|
|
75
|
+
"eslint-config-prettier": "^8.3.0",
|
|
76
|
+
"eslint-plugin-import": "^2.25.2",
|
|
77
|
+
"file-loader": "^6.2.0",
|
|
78
|
+
"fs-extra": "^9.1.0",
|
|
79
|
+
"husky": "^6.0.0",
|
|
80
|
+
"jest": "^27.3.1",
|
|
81
|
+
"lint-staged": "^10.5.4",
|
|
81
82
|
"npm-run-all": "^4.1.5",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
83
|
+
"postcss-scss": "^3.0.5",
|
|
84
|
+
"prettier": "^2.4.1",
|
|
85
|
+
"standard-version": "^9.3.2",
|
|
86
|
+
"stylelint": "^14.0.1",
|
|
87
|
+
"typescript": "^4.4.4",
|
|
88
|
+
"webpack": "^5.62.1"
|
|
87
89
|
},
|
|
88
90
|
"keywords": [
|
|
89
91
|
"stylelint",
|
package/CHANGELOG.md
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
### [2.1.1](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.3...v2.1.1) (2020-10-14)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Features
|
|
9
|
-
|
|
10
|
-
* support typescript ([#213](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/213)) ([b7dfa19](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/b7dfa195b7836bad7ac94a64a0c0a6163021a3e7))
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Bug Fixes
|
|
14
|
-
|
|
15
|
-
* avoiding https://github.com/mrmlnc/fast-glob/issues/158 ([#209](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/209)) ([14ae30d](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/14ae30df8a6d6b629c4e1fa647b4c6989377aec8))
|
|
16
|
-
* use better micromatch extglobs ([#216](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/216)) ([a70ed3d](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/a70ed3d6b6d8da90bf4dc371057cbe1433b4558d))
|
|
17
|
-
|
|
18
|
-
## [2.1.0](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.3...v2.1.0) (2020-06-17)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
### Features
|
|
22
|
-
|
|
23
|
-
* support typescript ([#213](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/213)) ([b7dfa19](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/b7dfa195b7836bad7ac94a64a0c0a6163021a3e7))
|
|
24
|
-
|
|
25
|
-
## [2.0.0](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.3...v2.0.0) (2020-05-04)
|
|
26
|
-
|
|
27
|
-
### ⚠ BREAKING CHANGES
|
|
28
|
-
|
|
29
|
-
* minimum supported Node.js version is `10.13`
|
|
30
|
-
* minimum supported stylelint version is `13.0.0`
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* avoiding https://github.com/mrmlnc/fast-glob/issues/158 ([#209](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/209)) ([14ae30d](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/14ae30df8a6d6b629c4e1fa647b4c6989377aec8))
|
|
35
|
-
|
|
36
|
-
### [1.2.3](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.2...v1.2.3) (2020-02-08)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Performance
|
|
40
|
-
|
|
41
|
-
* require lint of stylelint only one time ([#207](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/207)) ([7e2495e](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/7e2495e6ba4d8cebb7f07cc9418020ea494670f8))
|
|
42
|
-
|
|
43
|
-
### [1.2.2](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.1...v1.2.2) (2020-02-08)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### Bug Fixes
|
|
47
|
-
|
|
48
|
-
* replace back slashes on changed files ([#206](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/206)) ([7508028](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/7508028398d366c37d1a14e254baec9dc39b816c))
|
|
49
|
-
|
|
50
|
-
### [1.2.1](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.2.0...v1.2.1) (2020-01-16)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### Bug Fixes
|
|
54
|
-
|
|
55
|
-
* compatibility stylelint v13 ([#204](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/204)) ([483be31](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/483be318450ec9a4f9eeb4bf1b1db203ba0c863d))
|
|
56
|
-
|
|
57
|
-
## [1.2.0](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.1.2...v1.2.0) (2020-01-13)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### Features
|
|
61
|
-
|
|
62
|
-
* make possible to define official formatter as string ([#202](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/202)) ([8d6599c](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/8d6599c3f2f0e26d1515b01f6ecbafabeaa68fac))
|
|
63
|
-
* support stylelint v13 ([#203](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/203)) ([6fb31a3](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/6fb31a3931cb9d7cb0ce8cc99c9db28f928c82f4))
|
|
64
|
-
|
|
65
|
-
### [1.1.2](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.1.1...v1.1.2) (2019-12-04)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
### Bug Fixes
|
|
69
|
-
|
|
70
|
-
* support webpack 5 ([#199](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/199)) ([3d9e544](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/3d9e544f31172b7c01f4bd7c7254cfc7e38466c9))
|
|
71
|
-
|
|
72
|
-
### [1.1.1](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.1.0...v1.1.1) (2019-12-01)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### Bug Fixes
|
|
76
|
-
|
|
77
|
-
* use hook `afterEmit` and emit error on catch ([17f7421](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/17f7421030e6a5b589b2cab015d9af80b868ca95))
|
|
78
|
-
|
|
79
|
-
## [1.1.0](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.4...v1.1.0) (2019-11-18)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
### Features
|
|
83
|
-
|
|
84
|
-
* support stylelint v12 ([#196](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/196)) ([aacf7ad](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/aacf7ad))
|
|
85
|
-
|
|
86
|
-
### [1.0.4](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.3...v1.0.4) (2019-11-13)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Bug Fixes
|
|
90
|
-
|
|
91
|
-
* hooks ([#195](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/195)) ([792fe19](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/792fe19))
|
|
92
|
-
|
|
93
|
-
### [1.0.3](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.2...v1.0.3) (2019-10-25)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
### Bug Fixes
|
|
97
|
-
|
|
98
|
-
* options variable ([#193](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/193)) ([3389aec](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/3389aec))
|
|
99
|
-
|
|
100
|
-
### [1.0.2](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.1...v1.0.2) (2019-10-07)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
### Bug Fixes
|
|
104
|
-
|
|
105
|
-
* convert back-slashes ([#186](https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/186)) ([41b0f53](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/41b0f53))
|
|
106
|
-
|
|
107
|
-
### [1.0.1](https://github.com/webpack-contrib/stylelint-webpack-plugin/compare/v1.0.0...v1.0.1) (2019-09-30)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
### Bug Fixes
|
|
111
|
-
|
|
112
|
-
* compiler hooks ([aca2c1d](https://github.com/webpack-contrib/stylelint-webpack-plugin/commit/aca2c1d))
|
|
113
|
-
|
|
114
|
-
## 1.0.0 (2019-09-30)
|
|
115
|
-
|
|
116
|
-
### Bug Fixes
|
|
117
|
-
|
|
118
|
-
* Handle compilation.fileTimestamps for webpack 4
|
|
119
|
-
* DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
|
|
120
|
-
* Update option `emitError`
|
|
121
|
-
* Update option `failOnError`
|
|
122
|
-
|
|
123
|
-
### Features
|
|
124
|
-
|
|
125
|
-
* Modernize project to latest defaults
|
|
126
|
-
* Validate options
|
|
127
|
-
* Support absolute paths in files array
|
|
128
|
-
* New option `stylelintPath`
|
|
129
|
-
* New option `emitWarning`
|
|
130
|
-
* New option `failOnWarning`
|
|
131
|
-
* New option `quiet`
|
|
132
|
-
|
|
133
|
-
### ⚠ BREAKING CHANGES
|
|
134
|
-
|
|
135
|
-
* Drop support for Node < 8.9.0
|
|
136
|
-
* Minimum supported `webpack` version is 4
|
|
137
|
-
* Minimum supported `stylelint` version is 9
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('webpack').Compiler} Compiler */
|
|
2
|
-
/** @typedef {import('./getOptions').Options} Options */
|
|
3
|
-
/** @typedef {import('./linter').Lint} Lint */
|
|
4
|
-
/** @typedef {import('./linter').LinterCallback} LinterCallback */
|
|
5
|
-
/** @typedef {Partial<{timestamp:number} | number>} FileSystemInfoEntry */
|
|
6
|
-
export default class LintDirtyModulesPlugin {
|
|
7
|
-
/**
|
|
8
|
-
* @param {Lint} lint
|
|
9
|
-
* @param {Compiler} compiler
|
|
10
|
-
* @param {Options} options
|
|
11
|
-
*/
|
|
12
|
-
constructor(lint: Lint, compiler: Compiler, options: Options);
|
|
13
|
-
lint: import('./linter').Lint;
|
|
14
|
-
compiler: import('webpack').Compiler;
|
|
15
|
-
options: import('./getOptions').Options;
|
|
16
|
-
startTime: number;
|
|
17
|
-
prevTimestamps: Map<any, any>;
|
|
18
|
-
isFirstRun: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* @param {Compiler} compilation
|
|
21
|
-
* @param {LinterCallback} callback
|
|
22
|
-
* @returns {void}
|
|
23
|
-
*/
|
|
24
|
-
apply(compilation: Compiler, callback: LinterCallback): void;
|
|
25
|
-
/**
|
|
26
|
-
* @param {Map<string, number|FileSystemInfoEntry>} fileTimestamps
|
|
27
|
-
* @param {string | ReadonlyArray<string>} glob
|
|
28
|
-
* @returns {Array<string>}
|
|
29
|
-
*/
|
|
30
|
-
getChangedFiles(
|
|
31
|
-
fileTimestamps: Map<
|
|
32
|
-
string,
|
|
33
|
-
| number
|
|
34
|
-
| Partial<{
|
|
35
|
-
timestamp: number;
|
|
36
|
-
}>
|
|
37
|
-
>,
|
|
38
|
-
glob: string | ReadonlyArray<string>
|
|
39
|
-
): Array<string>;
|
|
40
|
-
}
|
|
41
|
-
export type Compiler = import('webpack').Compiler;
|
|
42
|
-
export type Options = {
|
|
43
|
-
context?: string | undefined;
|
|
44
|
-
emitError?: boolean | undefined;
|
|
45
|
-
emitWarning?: boolean | undefined;
|
|
46
|
-
failOnError?: boolean | undefined;
|
|
47
|
-
failOnWarning?: boolean | undefined;
|
|
48
|
-
files: string | string[];
|
|
49
|
-
formatter: TimerHandler;
|
|
50
|
-
lintDirtyModulesOnly?: boolean | undefined;
|
|
51
|
-
quiet?: boolean | undefined;
|
|
52
|
-
stylelintPath: string;
|
|
53
|
-
};
|
|
54
|
-
export type Lint = (
|
|
55
|
-
options: import('./getOptions').Options
|
|
56
|
-
) => Promise<import('stylelint').LinterResult>;
|
|
57
|
-
export type LinterCallback = (
|
|
58
|
-
error?: import('./StylelintError').default | null | undefined
|
|
59
|
-
) => void;
|
|
60
|
-
export type FileSystemInfoEntry =
|
|
61
|
-
| number
|
|
62
|
-
| Partial<{
|
|
63
|
-
timestamp: number;
|
|
64
|
-
}>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** @typedef {import("stylelint")} stylelint */
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {Object} Options
|
|
4
|
-
* @property {string=} context
|
|
5
|
-
* @property {boolean=} emitError
|
|
6
|
-
* @property {boolean=} emitWarning
|
|
7
|
-
* @property {boolean=} failOnError
|
|
8
|
-
* @property {boolean=} failOnWarning
|
|
9
|
-
* @property {Array<string> | string} files
|
|
10
|
-
* @property {Function | string} formatter
|
|
11
|
-
* @property {boolean=} lintDirtyModulesOnly
|
|
12
|
-
* @property {boolean=} quiet
|
|
13
|
-
* @property {string} stylelintPath
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @param {Partial<Options>} pluginOptions
|
|
17
|
-
* @returns {Options}
|
|
18
|
-
*/
|
|
19
|
-
export default function getOptions(pluginOptions: Partial<Options>): Options;
|
|
20
|
-
export type stylelint = typeof import('stylelint');
|
|
21
|
-
export type Options = {
|
|
22
|
-
context?: string | undefined;
|
|
23
|
-
emitError?: boolean | undefined;
|
|
24
|
-
emitWarning?: boolean | undefined;
|
|
25
|
-
failOnError?: boolean | undefined;
|
|
26
|
-
failOnWarning?: boolean | undefined;
|
|
27
|
-
files: Array<string> | string;
|
|
28
|
-
formatter: Function | string;
|
|
29
|
-
lintDirtyModulesOnly?: boolean | undefined;
|
|
30
|
-
quiet?: boolean | undefined;
|
|
31
|
-
stylelintPath: string;
|
|
32
|
-
};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _micromatch = require("micromatch");
|
|
9
|
-
|
|
10
|
-
var _linter = _interopRequireDefault(require("./linter"));
|
|
11
|
-
|
|
12
|
-
var _utils = require("./utils");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
/** @typedef {import('webpack').Compiler} Compiler */
|
|
17
|
-
|
|
18
|
-
/** @typedef {import('./getOptions').Options} Options */
|
|
19
|
-
|
|
20
|
-
/** @typedef {import('./linter').Lint} Lint */
|
|
21
|
-
|
|
22
|
-
/** @typedef {import('./linter').LinterCallback} LinterCallback */
|
|
23
|
-
|
|
24
|
-
/** @typedef {Partial<{timestamp:number} | number>} FileSystemInfoEntry */
|
|
25
|
-
class LintDirtyModulesPlugin {
|
|
26
|
-
/**
|
|
27
|
-
* @param {Lint} lint
|
|
28
|
-
* @param {Compiler} compiler
|
|
29
|
-
* @param {Options} options
|
|
30
|
-
*/
|
|
31
|
-
constructor(lint, compiler, options) {
|
|
32
|
-
this.lint = lint;
|
|
33
|
-
this.compiler = compiler;
|
|
34
|
-
this.options = options;
|
|
35
|
-
this.startTime = Date.now();
|
|
36
|
-
this.prevTimestamps = new Map();
|
|
37
|
-
this.isFirstRun = true;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @param {Compiler} compilation
|
|
41
|
-
* @param {LinterCallback} callback
|
|
42
|
-
* @returns {void}
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
apply(compilation, callback) {
|
|
47
|
-
const fileTimestamps = compilation.fileTimestamps || new Map();
|
|
48
|
-
|
|
49
|
-
if (this.isFirstRun) {
|
|
50
|
-
this.isFirstRun = false;
|
|
51
|
-
this.prevTimestamps = fileTimestamps;
|
|
52
|
-
callback();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const dirtyOptions = { ...this.options
|
|
57
|
-
}; // @ts-ignore
|
|
58
|
-
|
|
59
|
-
const glob = (0, _utils.replaceBackslashes)(dirtyOptions.files.join('|'));
|
|
60
|
-
const changedFiles = this.getChangedFiles(fileTimestamps, glob);
|
|
61
|
-
this.prevTimestamps = fileTimestamps;
|
|
62
|
-
|
|
63
|
-
if (changedFiles.length) {
|
|
64
|
-
dirtyOptions.files = changedFiles;
|
|
65
|
-
(0, _linter.default)(this.lint, dirtyOptions, this.compiler, callback);
|
|
66
|
-
} else {
|
|
67
|
-
callback();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @param {Map<string, number|FileSystemInfoEntry>} fileTimestamps
|
|
72
|
-
* @param {string | ReadonlyArray<string>} glob
|
|
73
|
-
* @returns {Array<string>}
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
getChangedFiles(fileTimestamps, glob) {
|
|
78
|
-
/**
|
|
79
|
-
* @param {FileSystemInfoEntry} fileSystemInfoEntry
|
|
80
|
-
* @returns {Partial<number>}
|
|
81
|
-
*/
|
|
82
|
-
const getTimestamps = fileSystemInfoEntry => {
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
if (fileSystemInfoEntry && fileSystemInfoEntry.timestamp) {
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
return fileSystemInfoEntry.timestamp;
|
|
87
|
-
} // @ts-ignore
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return fileSystemInfoEntry;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* @param {string} filename
|
|
94
|
-
* @param {FileSystemInfoEntry} fileSystemInfoEntry
|
|
95
|
-
* @returns {boolean}
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const hasFileChanged = (filename, fileSystemInfoEntry) => {
|
|
100
|
-
const prevTimestamp = getTimestamps(this.prevTimestamps.get(filename));
|
|
101
|
-
const timestamp = getTimestamps(fileSystemInfoEntry);
|
|
102
|
-
return (prevTimestamp || this.startTime) < (timestamp || Infinity);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const changedFiles = [];
|
|
106
|
-
|
|
107
|
-
for (const [filename, timestamp] of fileTimestamps.entries()) {
|
|
108
|
-
if (hasFileChanged(filename, timestamp) && (0, _micromatch.isMatch)(filename, glob)) {
|
|
109
|
-
changedFiles.push((0, _utils.replaceBackslashes)(filename));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return changedFiles;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
exports.default = LintDirtyModulesPlugin;
|
package/dist/getOptions.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = getOptions;
|
|
7
|
-
|
|
8
|
-
var _schemaUtils = require("schema-utils");
|
|
9
|
-
|
|
10
|
-
var _options = _interopRequireDefault(require("./options.json"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
/** @typedef {import("stylelint")} stylelint */
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @typedef {Object} Options
|
|
18
|
-
* @property {string=} context
|
|
19
|
-
* @property {boolean=} emitError
|
|
20
|
-
* @property {boolean=} emitWarning
|
|
21
|
-
* @property {boolean=} failOnError
|
|
22
|
-
* @property {boolean=} failOnWarning
|
|
23
|
-
* @property {Array<string> | string} files
|
|
24
|
-
* @property {Function | string} formatter
|
|
25
|
-
* @property {boolean=} lintDirtyModulesOnly
|
|
26
|
-
* @property {boolean=} quiet
|
|
27
|
-
* @property {string} stylelintPath
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param {Partial<Options>} pluginOptions
|
|
32
|
-
* @returns {Options}
|
|
33
|
-
*/
|
|
34
|
-
function getOptions(pluginOptions) {
|
|
35
|
-
const options = {
|
|
36
|
-
files: '**/*.(s(c|a)ss|css)',
|
|
37
|
-
formatter: 'string',
|
|
38
|
-
stylelintPath: 'stylelint',
|
|
39
|
-
...pluginOptions
|
|
40
|
-
}; // @ts-ignore
|
|
41
|
-
|
|
42
|
-
(0, _schemaUtils.validate)(_options.default, options, {
|
|
43
|
-
name: 'Stylelint Webpack Plugin',
|
|
44
|
-
baseDataPath: 'options'
|
|
45
|
-
}); // eslint-disable-next-line
|
|
46
|
-
|
|
47
|
-
const stylelint = require(options.stylelintPath);
|
|
48
|
-
|
|
49
|
-
options.formatter = getFormatter(stylelint, options.formatter);
|
|
50
|
-
return options;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* @param {stylelint} stylelint
|
|
54
|
-
* @param {Function | string} formatter
|
|
55
|
-
* @returns {Function}
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
function getFormatter({
|
|
60
|
-
formatters
|
|
61
|
-
}, formatter) {
|
|
62
|
-
if (typeof formatter === 'function') {
|
|
63
|
-
return formatter;
|
|
64
|
-
} // Try to get oficial formatter
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (typeof formatter === 'string' && // @ts-ignore
|
|
68
|
-
typeof formatters[formatter] === 'function') {
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
return formatters[formatter];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return formatters.string;
|
|
74
|
-
}
|