Skip to content

Commit

Permalink
fix: prevent lint all files (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza authored Feb 12, 2021
1 parent be0391e commit f57cb8e
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,28 @@ class ESLintWebpackPlugin {
return;
}

// Gather Files to lint
compilation.hooks.finishModules.tap(ESLINT_PLUGIN, (modules) => {
/** @type {string[]} */
const files = [];
/** @type {string[]} */
const files = [];

// @ts-ignore
for (const { resource } of modules) {
if (resource) {
const [file] = resource.split('?');

if (
file &&
!files.includes(file) &&
isMatch(file, wanted) &&
!isMatch(file, exclude)
) {
files.push(file);
}
// @ts-ignore
// Add the file to be linted
compilation.hooks.succeedModule.tap(ESLINT_PLUGIN, ({ resource }) => {
if (resource) {
const [file] = resource.split('?');

if (
file &&
!files.includes(file) &&
isMatch(file, wanted) &&
!isMatch(file, exclude)
) {
files.push(file);
}
}
});

// Lint all files added
compilation.hooks.finishModules.tap(ESLINT_PLUGIN, () => {
if (files.length > 0) {
lint(files);
}
Expand Down

0 comments on commit f57cb8e

Please sign in to comment.