Skip to content

Commit

Permalink
refactor: finishModules
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed Feb 4, 2021
1 parent d0068c4 commit 354d489
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,24 @@ class ESLintWebpackPlugin {
return;
}

const seen = new Set();

// Gather Files to lint
compilation.hooks.finishModules.tap(ESLINT_PLUGIN, (modules) => {
const resources = Array.from(modules)
// @ts-ignore
.filter((module) => module.resource)
// @ts-ignore
.map(({ resource }) => resource.split('?')[0])
.filter(
(resource) =>
resource &&
!seen.has(resource) &&
isMatch(resource, wanted) &&
!isMatch(resource, exclude)
);

resources.forEach((resource) => seen.add(resource));

if (resources.length > 0) {
lint(resources);
const resources = new Set(
Array.from(modules)
// @ts-ignore
.filter((module) => module.resource)
// @ts-ignore
.map(({ resource }) => resource.split('?')[0])
.filter(
(resource) =>
resource &&
isMatch(resource, wanted) &&
!isMatch(resource, exclude)
)
);

if (resources.size > 0) {
lint(Array.from(resources));
}
});

Expand Down

0 comments on commit 354d489

Please sign in to comment.