microsoft/vscode-eslint

Bug: In VSCode, when an incorrect config breaks the ESLint server, the "Restart ESLint Server" command does not work

ppseprus opened this issue · 0 comments

Environment

Node version: 20.12.2
npm version: 10.5.2
Local ESLint version: 9.5.0
VSCode extension version: 2.4.4
Global ESLint version: none
VSCode version: 1.90.1
Operating System: macOS Sonoma 14.5 (23F79)

What parser are you using?

Default (Espree)

What did you do?

Configuration
// eslint.config.js
export default [{
  rules: {
    "no-unused-vars": "error",
  }
}]

Steps to Reproduce

  1. Using the above minimal config, have the ESLint server up and running in VSCode
[Info  - 10:43:36 PM] ESLint server is starting.
[Info  - 10:43:37 PM] ESLint server running in node v20.9.0
[Info  - 10:43:37 PM] ESLint server is running.
[Info  - 10:43:37 PM] ESLint library loaded from: /Users/[...]/node_modules/eslint/lib/api.js
  1. Break the config by misconfiguring it (eg. add ignore instead of ignores) and hit save
[Error - 10:47:47 PM] An unexpected error occurred:
[Error - 10:47:47 PM] ConfigError: Config (unnamed): Unexpected key "ignore" found.
  1. Remove / fix the incorrect and hit save
  2. Open the Command Palette (cmd + shift + P) and select "ESLint: Restart ESLint Server"
  3. Open the Command Palette (cmd + shift + P) and select "ESLint: Show Output Channel"

What did you expect to happen?

The ESLint plugin to restart and work correctly.

What actually happened?

After the restart, the ESLint server exits.

...
[Error - 10:49:40 PM] Server process exited with code 0.

The developer has to reload VSCode to get it working again.

Link to Minimal Reproducible Example

https://github.com/ppseprus/vscode-eslint-bug

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

The same thing happens, when the config is provided via a *.json file and there's a trailing comma at the last line. Incorrectly formatted *.json breaks the server and the restart does not seem to work event after the issue is fixed.