nuxt / eslint

Collection of ESLint-related packages for Nuxt
https://eslint.nuxt.com
MIT License
539 stars 65 forks source link

Eslint crashing when using custom config preset #389

Closed Ragura closed 5 months ago

Ragura commented 5 months ago

Environment

Package

@nuxt/eslint

Reproduction

https://github.com/Ragura/antfu-eslint-config-repro

Describe the bug

There appears to be an issue with custom config presets like Antfu's eslint-config crashing the ESLint server in VSCode any time the config changes after initialization. I have set it up like the docs instruct and it works perfectly until something changes. The linked reproduction has a simple way to spot the issue. In App.vue there's a line with an unused variable. ESLint will call it out. Now change something in eslint.config.mjs, even if it's just adding a space. The ESLint server will crash with this error:

ConfigError: Config "antfu/test/setup": Key "plugins": Cannot redefine plugin "test".
    at rethrowConfigError (/Users/me/development/project/node_modules/@humanwhocodes/config-array/api.js:225:8)
    at /Users/me/development/project/node_modules/@humanwhocodes/config-array/api.js:1018:5
    at Array.reduce (<anonymous>)
    at FlatConfigArray.getConfig (/Users/me/development/project/node_modules/@humanwhocodes/config-array/api.js:1014:39)
    at ESLint.calculateConfigForFile (/Users/me/development/project/node_modules/eslint/lib/eslint/eslint.js:1175:24)
    at async ESLint.isPathIgnored (/Users/me/development/project/node_modules/eslint/lib/eslint/eslint.js:1197:24)
    at async ESLint.lintText (/Users/me/development/project/node_modules/eslint/lib/eslint/eslint.js:1034:33)
    at async /Users/me/.vscode-insiders/extensions/dbaeumer.vscode-eslint-3.0.5/server/out/eslintServer.js:1:26928
    at async M (/Users/me/.vscode-insiders/extensions/dbaeumer.vscode-eslint-3.0.5/server/out/eslintServer.js:1:19754)
    at async /Users/me/.vscode-insiders/extensions/dbaeumer.vscode-eslint-3.0.5/server/out/eslintServer.js:1:233425

It's not a huge issue, but I wanted to report it anyway because Nuxt usually doesn't require restarting services to adapt to changes in config files.

Additional context

No response

Logs

No response

antfu commented 5 months ago

This sounds like an ESLint or VSCode ESLint bug. I will investigate.

Ragura commented 5 months ago

Thanks! I posted about it in your Discord channel earlier and I'll be around if you have questions or want me to test things out :)