@@ -19,6 +19,7 @@ class ESLintWebpackPlugin {
1919 * @param {Options } options
2020 */
2121 constructor ( options = { } ) {
22+ this . key = ESLINT_PLUGIN ;
2223 this . options = getOptions ( options ) ;
2324 this . run = this . run . bind ( this ) ;
2425 }
@@ -30,20 +31,20 @@ class ESLintWebpackPlugin {
3031 apply ( compiler ) {
3132 // Generate key for each compilation,
3233 // 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 ) } ` ;
3435
3536 // If `lintDirtyModulesOnly` is disabled,
3637 // execute the linter on the build
3738 if ( ! this . options . lintDirtyModulesOnly ) {
38- compiler . hooks . run . tapPromise ( ESLINT_PLUGIN , this . run ) ;
39+ compiler . hooks . run . tapPromise ( this . key , this . run ) ;
3940 }
4041
4142 // TODO: Figure out want `compiler.watching` is and how to use it in Webpack5.
4243 // From my testing of compiler.watch() ... compiler.watching is always
4344 // undefined (webpack 4 doesn't define it either) I'm leaving it out
4445 // for now.
4546 let isFirstRun = this . options . lintDirtyModulesOnly ;
46- compiler . hooks . watchRun . tapPromise ( ESLINT_PLUGIN , ( c ) => {
47+ compiler . hooks . watchRun . tapPromise ( this . key , ( c ) => {
4748 if ( isFirstRun ) {
4849 isFirstRun = false ;
4950
@@ -61,10 +62,7 @@ class ESLintWebpackPlugin {
6162 // Do not re-hook
6263 if (
6364 // @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 )
6866 ) {
6967 return ;
7068 }
@@ -85,7 +83,7 @@ class ESLintWebpackPlugin {
8583 [ ]
8684 ) ;
8785
88- compiler . hooks . thisCompilation . tap ( ESLINT_PLUGIN , ( compilation ) => {
86+ compiler . hooks . thisCompilation . tap ( this . key , ( compilation ) => {
8987 /** @type {import('./linter').Linter } */
9088 let lint ;
9189 /** @type {import('./linter').Reporter } */
@@ -103,7 +101,7 @@ class ESLintWebpackPlugin {
103101
104102 // @ts -ignore
105103 // Add the file to be linted
106- compilation . hooks . succeedModule . tap ( ESLINT_PLUGIN , ( { resource } ) => {
104+ compilation . hooks . succeedModule . tap ( this . key , ( { resource } ) => {
107105 if ( resource ) {
108106 const [ file ] = resource . split ( '?' ) ;
109107
@@ -119,17 +117,14 @@ class ESLintWebpackPlugin {
119117 } ) ;
120118
121119 // Lint all files added
122- compilation . hooks . finishModules . tap ( ESLINT_PLUGIN , ( ) => {
120+ compilation . hooks . finishModules . tap ( this . key , ( ) => {
123121 if ( files . length > 0 ) {
124122 lint ( files ) ;
125123 }
126124 } ) ;
127125
128126 // await and interpret results
129- compilation . hooks . additionalAssets . tapPromise (
130- ESLINT_PLUGIN ,
131- processResults
132- ) ;
127+ compilation . hooks . additionalAssets . tapPromise ( this . key , processResults ) ;
133128
134129 async function processResults ( ) {
135130 const { errors, warnings, generateReportAsset } = await report ( ) ;
0 commit comments