@@ -31,10 +31,28 @@ class ESLintWebpackPlugin {
3131 // this differentiates one from the other when being cached.
3232 this . key = compiler . name || `${ this . key } _${ ( counter += 1 ) } ` ;
3333
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+
3450 // If `lintDirtyModulesOnly` is disabled,
3551 // execute the linter on the build
3652 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+ ) ;
3856 }
3957
4058 let isFirstRun = this . options . lintDirtyModulesOnly ;
@@ -45,14 +63,17 @@ class ESLintWebpackPlugin {
4563 return Promise . resolve ( ) ;
4664 }
4765
48- return this . run ( c ) ;
66+ return this . run ( c , options , wanted , exclude ) ;
4967 } ) ;
5068 }
5169
5270 /**
5371 * @param {Compiler } compiler
72+ * @param {Options } options
73+ * @param {string[] } wanted
74+ * @param {string[] } exclude
5475 */
55- async run ( compiler ) {
76+ async run ( compiler , options , wanted , exclude ) {
5677 // Do not re-hook
5778 if (
5879 // @ts -ignore
@@ -61,22 +82,6 @@ class ESLintWebpackPlugin {
6182 return ;
6283 }
6384
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-
8085 compiler . hooks . thisCompilation . tap ( this . key , ( compilation ) => {
8186 /** @type {import('./linter').Linter } */
8287 let lint ;
0 commit comments