Code Monkey home page Code Monkey logo

Comments (11)

densk1 avatar densk1 commented on July 26, 2024 1

There is a watch mode test. Could you make a test case that fails?

I've modified watch.test.js. expect(message).toEqual(expect.stringMatching('prefer-const')); fails in thirdPass(). It passes in secondPass() but the file has not changed.

// 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();
    }
  });
});

from eslint-webpack-plugin.

ricardogobbosouza avatar ricardogobbosouza commented on July 26, 2024 1

@inker
I haven't released 2.4.1 yet 😬

from eslint-webpack-plugin.

jsg2021 avatar jsg2021 commented on July 26, 2024 1

@ricardogobbosouza I fixed one last edge case for this

from eslint-webpack-plugin.

jsg2021 avatar jsg2021 commented on July 26, 2024 1

the thread pool is now disabled by default. As a bonus, the pool will only be used for the initial completion.

from eslint-webpack-plugin.

densk1 avatar densk1 commented on July 26, 2024

Guessing, by reading changes, but is it possibly related to this:

apply(compiler) {
if (!this.options.lintDirtyModulesOnly) {
compiler.hooks.run.tapPromise(ESLINT_PLUGIN, this.run);
}
// TODO: Figure out want `compiler.watching` is and how to use it in Webpack5.
// From my testing of compiler.watch() ... compiler.watching is always
// undefined (webpack 4 doesn't define it either) I'm leaving it out
// for now.
compiler.hooks.watchRun.tapPromise(ESLINT_PLUGIN, this.run);
}

and this

async run(compiler) {
// Do not re-hook
if (
// @ts-ignore
compiler.hooks.thisCompilation.taps.find(
// @ts-ignore
({ name }) => name === ESLINT_PLUGIN
)

Blocking re-running of this.run for watch?

from eslint-webpack-plugin.

jsg2021 avatar jsg2021 commented on July 26, 2024

There is a watch mode test. Could you make a test case that fails?

from eslint-webpack-plugin.

jsg2021 avatar jsg2021 commented on July 26, 2024

Guessing, by reading changes, but is it possibly related to this:

apply(compiler) {
if (!this.options.lintDirtyModulesOnly) {
compiler.hooks.run.tapPromise(ESLINT_PLUGIN, this.run);
}
// TODO: Figure out want `compiler.watching` is and how to use it in Webpack5.
// From my testing of compiler.watch() ... compiler.watching is always
// undefined (webpack 4 doesn't define it either) I'm leaving it out
// for now.
compiler.hooks.watchRun.tapPromise(ESLINT_PLUGIN, this.run);
}

and this

async run(compiler) {
// Do not re-hook
if (
// @ts-ignore
compiler.hooks.thisCompilation.taps.find(
// @ts-ignore
({ name }) => name === ESLINT_PLUGIN
)

Blocking re-running of this.run for watch?

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.

from eslint-webpack-plugin.

refaelok avatar refaelok commented on July 26, 2024

I have the exact same issue.
I'm following this issue and waiting for the next fix.

from eslint-webpack-plugin.

inker avatar inker commented on July 26, 2024

Still occurring in 2.4.0.

from eslint-webpack-plugin.

refaelok avatar refaelok commented on July 26, 2024

actually the issue was fixed but created another performance issue.
now for each change in some file the build open new nodejs process and take more memory from cpu, that mean while you cding and saving in big projects, you get performance issue, due to for 3 with interval of few seconds create performance issue.

from eslint-webpack-plugin.

inker avatar inker commented on July 26, 2024

Works in 2.4.1. Thanks.

from eslint-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.