Skip to content

Commit f57cb8e

Browse files
fix: prevent lint all files (#77)
1 parent be0391e commit f57cb8e

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/index.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,28 @@ class ESLintWebpackPlugin {
9898
return;
9999
}
100100

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

106-
// @ts-ignore
107-
for (const { resource } of modules) {
108-
if (resource) {
109-
const [file] = resource.split('?');
110-
111-
if (
112-
file &&
113-
!files.includes(file) &&
114-
isMatch(file, wanted) &&
115-
!isMatch(file, exclude)
116-
) {
117-
files.push(file);
118-
}
104+
// @ts-ignore
105+
// Add the file to be linted
106+
compilation.hooks.succeedModule.tap(ESLINT_PLUGIN, ({ resource }) => {
107+
if (resource) {
108+
const [file] = resource.split('?');
109+
110+
if (
111+
file &&
112+
!files.includes(file) &&
113+
isMatch(file, wanted) &&
114+
!isMatch(file, exclude)
115+
) {
116+
files.push(file);
119117
}
120118
}
119+
});
121120

121+
// Lint all files added
122+
compilation.hooks.finishModules.tap(ESLINT_PLUGIN, () => {
122123
if (files.length > 0) {
123124
lint(files);
124125
}

0 commit comments

Comments
 (0)