Skip to content
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

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

Open
musikele opened this issue Nov 15, 2024 · 0 comments
Open

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

musikele opened this issue Nov 15, 2024 · 0 comments

Comments

@musikele
Copy link

musikele commented Nov 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant