19

I have made the porting to eslint-webpack-plugin and I am getting the error "ESLint is not a constructor", the relevant snippet code is:

const ESLintPlugin = require('eslint-webpack-plugin');

  const plugins = [
    new webpack.DefinePlugin(productionEnvironmentVariables),
    new ESLintPlugin({
      overrideConfigFile: path.resolve(configPath, '.eslintrc.json')
    })
  ];

Any idea what is wrong? I have tried also with new ESLintPlugin() and ESLintPlugin({}).

Webpack version is ^4.44.2 Eslint version is ^6.8.0 eslint-webpack-plugin is ^2.1.0

Thank you in advance and regards.

Javier Guzmán
  • 1,014
  • 2
  • 13
  • 27

3 Answers3

39

You also need to install eslint >= 7 from npm, if you haven't already:

npm

npm i -D eslint@7.32.0

yarn

yarn add -D eslint@7.32.0
Liran H
  • 9,143
  • 7
  • 39
  • 52
hanyi tim
  • 401
  • 4
  • 3
1

I got this error while building vue app and had node > v18 .This worked for me eslint@7.32.0 .But not the latest eslint version installation.

Dolly
  • 11
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 28 '22 at 01:40
0

Just install eslint pack with the latest version, it work for me.

npm i eslint@latest -D
L.cheng
  • 1
  • 1