@@ -31,10 +31,28 @@ class ESLintWebpackPlugin {
31
31
// this differentiates one from the other when being cached.
32
32
this . key = compiler . name || `${ this . key } _${ ( counter += 1 ) } ` ;
33
33
34
+ const options = {
35
+ ...this . options ,
36
+ exclude : parseFiles (
37
+ this . options . exclude || [ ] ,
38
+ this . getContext ( compiler )
39
+ ) ,
40
+ extensions : arrify ( this . options . extensions ) ,
41
+ files : parseFiles ( this . options . files || '' , this . getContext ( compiler ) ) ,
42
+ } ;
43
+
44
+ const wanted = parseFoldersToGlobs ( options . files , options . extensions ) ;
45
+ const exclude = parseFoldersToGlobs (
46
+ this . options . exclude ? options . exclude : '**/node_modules/**' ,
47
+ [ ]
48
+ ) ;
49
+
34
50
// If `lintDirtyModulesOnly` is disabled,
35
51
// execute the linter on the build
36
52
if ( ! this . options . lintDirtyModulesOnly ) {
37
- compiler . hooks . run . tapPromise ( this . key , this . run ) ;
53
+ compiler . hooks . run . tapPromise ( this . key , ( c ) =>
54
+ this . run ( c , options , wanted , exclude )
55
+ ) ;
38
56
}
39
57
40
58
let isFirstRun = this . options . lintDirtyModulesOnly ;
@@ -45,14 +63,17 @@ class ESLintWebpackPlugin {
45
63
return Promise . resolve ( ) ;
46
64
}
47
65
48
- return this . run ( c ) ;
66
+ return this . run ( c , options , wanted , exclude ) ;
49
67
} ) ;
50
68
}
51
69
52
70
/**
53
71
* @param {Compiler } compiler
72
+ * @param {Options } options
73
+ * @param {string[] } wanted
74
+ * @param {string[] } exclude
54
75
*/
55
- async run ( compiler ) {
76
+ async run ( compiler , options , wanted , exclude ) {
56
77
// Do not re-hook
57
78
if (
58
79
// @ts -ignore
@@ -61,22 +82,6 @@ class ESLintWebpackPlugin {
61
82
return ;
62
83
}
63
84
64
- const options = {
65
- ...this . options ,
66
- exclude : parseFiles (
67
- this . options . exclude || [ ] ,
68
- this . getContext ( compiler )
69
- ) ,
70
- extensions : arrify ( this . options . extensions ) ,
71
- files : parseFiles ( this . options . files || '' , this . getContext ( compiler ) ) ,
72
- } ;
73
-
74
- const wanted = parseFoldersToGlobs ( options . files , options . extensions ) ;
75
- const exclude = parseFoldersToGlobs (
76
- this . options . exclude ? options . exclude : '**/node_modules/**' ,
77
- [ ]
78
- ) ;
79
-
80
85
compiler . hooks . thisCompilation . tap ( this . key , ( compilation ) => {
81
86
/** @type {import('./linter').Linter } */
82
87
let lint ;
0 commit comments