Skip to content

"Maximum call stack size exceeded" when running with eslnt 9 #270

Open
@musikele

Description

@musikele

Bug report

Eslint version: 9.14
[email protected]
[email protected]

I am working on a legacy project, trying to upgrade some libraries; this is my attempt to upgrade eslint and eslint webpack plugin.

By using eslint 9, i am trying to use eslint flat config file. I know it's experimental support, so I decided to open a issue to maybe help stabilize the behaviour.

I am using CJS (require, module exports, etc.). It seems that ESLint uses ESM (import, export) internally.

My configuration is this:

new ESLintPlugin({
      configType: 'flat',
      eslintPath: 'eslint/use-at-your-own-risk',
      overrideConfigFile: true,
      overrideConfig: eslintConfig,
      formatter: require(
        rootDir + '/node_modules/eslint/lib/cli-engine/formatters/stylish'
      ),
    }),
  • overrideConfigFile: if I put the path of the file directly, for example by using:
      overrideConfigFile: path.resolve(rootDir + '/eslint.config.js'),

I get:

ERROR in [eslint] A dynamic import callback was not specified.

Which may be caused by the fact that the project is using CJS modules and eslint at some point is importing a dynamic import. Which one? Error is unfortunately silenced. That's why I put it to true.

  • overrideConfig: As a way to superate this error, I've decided to read the ESLint configuration by myself and pass it here as a JS object. This way I get: "Maximum call stack size exceeded".

  • formatter: the stylish formatter is imported dynamically by eslint, and this was causing issues, that's why I added the formatter option and read the conf directly.

Actual Behavior

ERROR in [eslint] Maximum call stack size exceeded

webpack 5.76.0 compiled with 1 error in 285 ms
ℹ 「wdm」: Failed to compile.

Expected Behavior

I should get the list of warnings like i would by running npx eslint ..

How Do We Reproduce?

Here's a repo with a reproduction of the issue https://github.com/musikele/eslint-webpack-bug

in file config/webpack.common.js you can see the ESLintWebpackPlugin configuration.

To see the error run: npm run serve 

To see that linting is working you can use npm run lint or npx eslint . 

Please paste the results of npx webpack-cli info here, and mention other relevant information

  System:
    OS: macOS 15.0.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 66.11 MB / 18.00 GB
  Binaries:
    Node: 20.13.1 - ~/.asdf/installs/nodejs/20.13.1/bin/node
    Yarn: 1.22.22 - ~/.asdf/installs/nodejs/20.13.1/bin/yarn
    npm: 10.9.0 - ~/.asdf/plugins/nodejs/shims/npm
  Packages:
    eslint-webpack-plugin: ^4.2.0 => 4.2.0 
    lodash-webpack-plugin: ^0.11.6 => 0.11.6 
    webpack: ^5.76.0 => 5.76.0 
    webpack-cli: ^4.7.0 => 4.7.0 
    webpack-dev-server: ^3.11.2 => 3.11.2 
    webpack-merge: ^5.7.3 => 5.7.3 

If i remove almost ALL plugins from the ESLint config file, it starts to work.

If I comment out ESLintWebpackPlugin, webpack works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions