stylelint-webpack-plugin 3.2.0 → 3.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 CHANGED
@@ -28,7 +28,7 @@ npm install stylelint-webpack-plugin --save-dev
28
28
  or
29
29
 
30
30
  ```console
31
- yarn add -D install stylelint-webpack-plugin
31
+ yarn add -D stylelint-webpack-plugin
32
32
  ```
33
33
 
34
34
  or
@@ -5,7 +5,7 @@ class StylelintError extends Error {
5
5
  * @param {string=} messages
6
6
  */
7
7
  constructor(messages) {
8
- super(messages);
8
+ super(`[stylelint] ${messages}`);
9
9
  this.name = 'StylelintError';
10
10
  this.stack = '';
11
11
  }
@@ -37,7 +37,7 @@ const cache = {};
37
37
 
38
38
  /** @typedef {{api: import('stylelint').InternalApi, stylelint: Stylelint, lintFiles: LintTask, cleanup: AsyncTask, threads: number, }} Linter */
39
39
 
40
- /** @typedef {import('jest-worker').Worker & {lintFiles: LintTask}} Worker */
40
+ /** @typedef {JestWorker & {lintFiles: LintTask}} Worker */
41
41
 
42
42
  /**
43
43
  * @param {Options} options
package/dist/index.js CHANGED
@@ -54,11 +54,21 @@ class StylelintWebpackPlugin {
54
54
  apply(compiler) {
55
55
  // Generate key for each compilation,
56
56
  // this differentiates one from the other when being cached.
57
- this.key = compiler.name || `${this.key}_${counter += 1}`; // If `lintDirtyModulesOnly` is disabled,
57
+ this.key = compiler.name || `${this.key}_${counter += 1}`;
58
+ const context = this.getContext(compiler);
59
+ const excludeDefault = ['**/node_modules/**', String(compiler.options.output.path)];
60
+ const options = { ...this.options,
61
+ context,
62
+ exclude: parseFiles(this.options.exclude || excludeDefault, context),
63
+ extensions: arrify(this.options.extensions),
64
+ files: parseFiles(this.options.files || '', context)
65
+ };
66
+ const wanted = parseFoldersToGlobs(options.files, options.extensions);
67
+ const exclude = parseFoldersToGlobs(options.exclude); // If `lintDirtyModulesOnly` is disabled,
58
68
  // execute the linter on the build
59
69
 
60
70
  if (!this.options.lintDirtyModulesOnly) {
61
- compiler.hooks.run.tapPromise(this.key, this.run);
71
+ compiler.hooks.run.tapPromise(this.key, c => this.run(c, options, wanted, exclude));
62
72
  }
63
73
 
64
74
  let isFirstRun = this.options.lintDirtyModulesOnly;
@@ -68,15 +78,18 @@ class StylelintWebpackPlugin {
68
78
  return Promise.resolve();
69
79
  }
70
80
 
71
- return this.run(c);
81
+ return this.run(c, options, wanted, exclude);
72
82
  });
73
83
  }
74
84
  /**
75
85
  * @param {Compiler} compiler
86
+ * @param {Options} options
87
+ * @param {string[]} wanted
88
+ * @param {string[]} exclude
76
89
  */
77
90
 
78
91
 
79
- async run(compiler) {
92
+ async run(compiler, options, wanted, exclude) {
80
93
  // Do not re-hook
81
94
 
82
95
  /* istanbul ignore if */
@@ -87,15 +100,6 @@ class StylelintWebpackPlugin {
87
100
  return;
88
101
  }
89
102
 
90
- const context = this.getContext(compiler);
91
- const excludeDefault = ['**/node_modules/**', String(compiler.options.output.path)];
92
- const options = { ...this.options,
93
- exclude: parseFiles(this.options.exclude || excludeDefault, context),
94
- extensions: arrify(this.options.extensions),
95
- files: parseFiles(this.options.files || '', context)
96
- };
97
- const wanted = parseFoldersToGlobs(options.files, options.extensions);
98
- const exclude = parseFoldersToGlobs(options.exclude);
99
103
  compiler.hooks.thisCompilation.tap(this.key, compilation => {
100
104
  /** @type {import('./linter').Linter} */
101
105
  let lint;
@@ -141,10 +145,10 @@ class StylelintWebpackPlugin {
141
145
 
142
146
  if (threads > 1) {
143
147
  for (const file of files) {
144
- lint(parseFiles(file, context));
148
+ lint(parseFiles(file, options.context || ''));
145
149
  }
146
150
  } else if (files.length > 0) {
147
- lint(parseFiles(files, context));
151
+ lint(parseFiles(files, options.context || ''));
148
152
  }
149
153
  }); // await and interpret results
150
154
 
package/dist/linter.js CHANGED
@@ -98,7 +98,8 @@ function linter(key, options, compilation) {
98
98
  }
99
99
 
100
100
  rawResults.push(lintFiles(files).catch(e => {
101
- compilation.errors.push(e);
101
+ // @ts-ignore
102
+ compilation.errors.push(new StylelintError(e.message));
102
103
  return [];
103
104
  }));
104
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylelint-webpack-plugin",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "A Stylelint plugin for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/stylelint-webpack-plugin",
@@ -46,16 +46,16 @@
46
46
  "webpack": "^5.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "jest-worker": "^27.5.1",
49
+ "jest-worker": "^28.1.0",
50
50
  "globby": "^11.1.0",
51
- "micromatch": "^4.0.4",
51
+ "micromatch": "^4.0.5",
52
52
  "normalize-path": "^3.0.0",
53
53
  "schema-utils": "^4.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/cli": "^7.17.6",
57
- "@babel/core": "^7.17.7",
58
- "@babel/preset-env": "^7.16.11",
56
+ "@babel/cli": "^7.17.10",
57
+ "@babel/core": "^7.18.0",
58
+ "@babel/preset-env": "^7.18.0",
59
59
  "@commitlint/cli": "^16.2.3",
60
60
  "@commitlint/config-conventional": "^16.2.1",
61
61
  "@types/fs-extra": "^9.0.13",
@@ -64,26 +64,26 @@
64
64
  "@types/webpack": "^5.28.0",
65
65
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
66
66
  "babel-eslint": "^10.1.0",
67
- "babel-jest": "^27.5.1",
68
- "chokidar": "^3.5.2",
67
+ "babel-jest": "^28.1.0",
68
+ "chokidar": "^3.5.3",
69
69
  "cross-env": "^7.0.3",
70
- "del": "^6.0.0",
70
+ "del": "^6.1.0",
71
71
  "del-cli": "^4.0.1",
72
- "eslint": "^8.11.0",
72
+ "eslint": "^8.15.0",
73
73
  "eslint-config-prettier": "^8.5.0",
74
- "eslint-plugin-import": "^2.25.4",
74
+ "eslint-plugin-import": "^2.26.0",
75
75
  "file-loader": "^6.2.0",
76
- "fs-extra": "^10.0.1",
76
+ "fs-extra": "^10.1.0",
77
77
  "husky": "^7.0.4",
78
- "jest": "^27.5.1",
79
- "lint-staged": "^12.3.6",
78
+ "jest": "^28.1.0",
79
+ "lint-staged": "^12.4.1",
80
80
  "npm-run-all": "^4.1.5",
81
- "postcss-scss": "^4.0.3",
82
- "prettier": "^2.6.0",
83
- "standard-version": "^9.3.2",
84
- "stylelint": "^14.6.0",
81
+ "postcss-scss": "^4.0.4",
82
+ "prettier": "^2.6.2",
83
+ "standard-version": "^9.5.0",
84
+ "stylelint": "^14.8.2",
85
85
  "typescript": "^4.6.2",
86
- "webpack": "^5.70.0"
86
+ "webpack": "^5.72.1"
87
87
  },
88
88
  "keywords": [
89
89
  "stylelint",
@@ -86,6 +86,7 @@ type Stylelint = import('postcss').PluginCreator<
86
86
  type LintResult = import('stylelint').LintResult;
87
87
  type AsyncTask = () => Promise<void>;
88
88
  type LintTask = (files: string | string[]) => Promise<LintResult[]>;
89
- type Worker = import('jest-worker').Worker & {
89
+ type Worker = JestWorker & {
90
90
  lintFiles: LintTask;
91
91
  };
92
+ import { Worker as JestWorker } from 'jest-worker';
package/types/index.d.ts CHANGED
@@ -8,8 +8,16 @@ declare class StylelintWebpackPlugin {
8
8
  options: Partial<import('./options').PluginOptions>;
9
9
  /**
10
10
  * @param {Compiler} compiler
11
+ * @param {Options} options
12
+ * @param {string[]} wanted
13
+ * @param {string[]} exclude
11
14
  */
12
- run(compiler: Compiler): Promise<void>;
15
+ run(
16
+ compiler: Compiler,
17
+ options: Options,
18
+ wanted: string[],
19
+ exclude: string[]
20
+ ): Promise<void>;
13
21
  startTime: number;
14
22
  prevTimestamps: Map<any, any>;
15
23
  /**