@@ -19,6 +19,7 @@ class ESLintWebpackPlugin {
19
19
* @param {Options } options
20
20
*/
21
21
constructor ( options = { } ) {
22
+ this . key = ESLINT_PLUGIN ;
22
23
this . options = getOptions ( options ) ;
23
24
this . run = this . run . bind ( this ) ;
24
25
}
@@ -30,20 +31,20 @@ class ESLintWebpackPlugin {
30
31
apply ( compiler ) {
31
32
// Generate key for each compilation,
32
33
// this differentiates one from the other when being cached.
33
- this . key = compiler . name || `${ ESLINT_PLUGIN } _${ ( counter += 1 ) } ` ;
34
+ this . key = compiler . name || `${ this . key } _${ ( counter += 1 ) } ` ;
34
35
35
36
// If `lintDirtyModulesOnly` is disabled,
36
37
// execute the linter on the build
37
38
if ( ! this . options . lintDirtyModulesOnly ) {
38
- compiler . hooks . run . tapPromise ( ESLINT_PLUGIN , this . run ) ;
39
+ compiler . hooks . run . tapPromise ( this . key , this . run ) ;
39
40
}
40
41
41
42
// TODO: Figure out want `compiler.watching` is and how to use it in Webpack5.
42
43
// From my testing of compiler.watch() ... compiler.watching is always
43
44
// undefined (webpack 4 doesn't define it either) I'm leaving it out
44
45
// for now.
45
46
let isFirstRun = this . options . lintDirtyModulesOnly ;
46
- compiler . hooks . watchRun . tapPromise ( ESLINT_PLUGIN , ( c ) => {
47
+ compiler . hooks . watchRun . tapPromise ( this . key , ( c ) => {
47
48
if ( isFirstRun ) {
48
49
isFirstRun = false ;
49
50
@@ -61,10 +62,7 @@ class ESLintWebpackPlugin {
61
62
// Do not re-hook
62
63
if (
63
64
// @ts -ignore
64
- compiler . hooks . thisCompilation . taps . find (
65
- // @ts -ignore
66
- ( { name } ) => name === ESLINT_PLUGIN
67
- )
65
+ compiler . hooks . thisCompilation . taps . find ( ( { name } ) => name === this . key )
68
66
) {
69
67
return ;
70
68
}
@@ -85,7 +83,7 @@ class ESLintWebpackPlugin {
85
83
[ ]
86
84
) ;
87
85
88
- compiler . hooks . thisCompilation . tap ( ESLINT_PLUGIN , ( compilation ) => {
86
+ compiler . hooks . thisCompilation . tap ( this . key , ( compilation ) => {
89
87
/** @type {import('./linter').Linter } */
90
88
let lint ;
91
89
/** @type {import('./linter').Reporter } */
@@ -103,7 +101,7 @@ class ESLintWebpackPlugin {
103
101
104
102
// @ts -ignore
105
103
// Add the file to be linted
106
- compilation . hooks . succeedModule . tap ( ESLINT_PLUGIN , ( { resource } ) => {
104
+ compilation . hooks . succeedModule . tap ( this . key , ( { resource } ) => {
107
105
if ( resource ) {
108
106
const [ file ] = resource . split ( '?' ) ;
109
107
@@ -119,17 +117,14 @@ class ESLintWebpackPlugin {
119
117
} ) ;
120
118
121
119
// Lint all files added
122
- compilation . hooks . finishModules . tap ( ESLINT_PLUGIN , ( ) => {
120
+ compilation . hooks . finishModules . tap ( this . key , ( ) => {
123
121
if ( files . length > 0 ) {
124
122
lint ( files ) ;
125
123
}
126
124
} ) ;
127
125
128
126
// await and interpret results
129
- compilation . hooks . additionalAssets . tapPromise (
130
- ESLINT_PLUGIN ,
131
- processResults
132
- ) ;
127
+ compilation . hooks . additionalAssets . tapPromise ( this . key , processResults ) ;
133
128
134
129
async function processResults ( ) {
135
130
const { errors, warnings, generateReportAsset } = await report ( ) ;
0 commit comments