-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only lints and shows errors for most recently saved file in watch mode #44
Comments
Guessing, by reading changes, but is it possibly related to this: eslint-webpack-plugin/src/index.js Lines 28 to 38 in 8287872
and this eslint-webpack-plugin/src/index.js Lines 43 to 50 in 8287872
Blocking re-running of |
There is a watch mode test. Could you make a test case that fails? |
The run method is probably miss named. It's actually registering hooks to a compiler. For watch mode, that compiler lives for the duration of your watch. So those hooks are already present it skips and let's the original hooks process each compilation. |
I've modified // watch.test.js
import { join } from 'path';
import { writeFileSync } from 'fs';
import { removeSync } from 'fs-extra';
import pack from './utils/pack';
const target = join(__dirname, 'fixtures', 'watch-entry.js');
const target2 = join(__dirname, 'fixtures', 'watch-entry-2.js');
const targetExpectedPattern = expect.stringMatching(
target.replace(/\\/g, '\\\\')
);
describe('watch', () => {
afterEach(() => {
removeSync(target);
});
it('should watch', (done) => {
const compiler = pack('good');
const watch = compiler.watch({}, (err, stats) => {
watch.close();
expect(err).toBeNull();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(false);
done();
});
});
it('should watch with unique messages', (done) => {
writeFileSync(target, 'var foo = stuff\n');
let next = firstPass;
const compiler = pack('watch');
const watch = compiler.watch({}, (err, stats) => next(err, stats));
function firstPass(err, stats) {
expect(err).toBeNull();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
const { errors } = stats.compilation;
expect(errors.length).toBe(1);
const [{ message }] = errors;
expect(message).toEqual(targetExpectedPattern);
expect(message).toEqual(expect.stringMatching('\\(3 errors,'));
next = secondPass;
writeFileSync(target2, "let bar = false;\n");
writeFileSync(target, "const x = require('./watch-entry-2.js')\n\nconst foo = false;\n");
}
function secondPass(err, stats) {
expect(err).toBeNull();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
const { errors } = stats.compilation;
expect(errors.length).toBe(1);
const [{ message }] = errors;
expect(message).toEqual(targetExpectedPattern);
expect(message).toEqual(expect.stringMatching('no-unused-vars'));
expect(message).toEqual(expect.stringMatching('prefer-const')); // `prefer-const` passes here
expect(message).toEqual(expect.stringMatching('\\(4 errors,'));
next = thirdPass;
writeFileSync(target, "const x = require('./watch-entry-2.js')\nconst foo = 0\n");
}
function thirdPass(err, stats) {
expect(err).toBeNull();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
const { errors } = stats.compilation;
expect(errors.length).toBe(1);
const [{ message }] = errors;
expect(message).toEqual(targetExpectedPattern);
expect(message).toEqual(expect.stringMatching('no-unused-vars'));
expect(message).toEqual(expect.stringMatching('prefer-const')); // `prefer-const` fails here
expect(message).toEqual(expect.stringMatching('\\(1 error,'));
next = finish;
writeFileSync(
target,
'/* eslint-disable no-unused-vars */\nconst foo = false;\n'
);
}
function finish(err, stats) {
watch.close();
expect(err).toBeNull();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(false);
done();
}
});
}); |
I have the exact same issue. |
Still occurring in 2.4.0. |
@inker |
@ricardogobbosouza I fixed one last edge case for this |
actually the issue was fixed but created another performance issue. |
the thread pool is now disabled by default. As a bonus, the pool will only be used for the initial completion. |
Works in 2.4.1. Thanks. |
Expected Behavior
When in watch mode, each time I save a file, all files in the tree are linted.
Actual Behavior
When in Webpack watch mode, on start it lints and shows errors for both
A.ts
and fileB.ts
in the linting path. When I saveA.ts
it only checks and displays errors forA.ts
. When I saveB.ts
, , it then only lints and shows errors for file B.Code
How Do We Reproduce?
Switch between files with linting errors in them, and save each one while in watch mode on
v2.3.0
.Fix / Work around
I have reverted back to
v2.1.0
The text was updated successfully, but these errors were encountered: