emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.77k stars 882 forks source link

LSP-ESLint should support eslint.config.js-files #4341

Open 4lph4-Ph4un opened 7 months ago

4lph4-Ph4un commented 7 months ago

The newer versions of ESLint read configurations from eslint.config.js-files and many new JavaScript/TypeScript-projects already define their configurations this way. This file should be added to the files lsp-mode searches for configuration when initializing the client!

More about this here: https://eslint.org/docs/latest/use/configure/configuration-files-new Note that the disclaimer is outdated and nowadays you can just use the file without specifying any of the flags on the disclaimer. The flat-config is on by default!

Apart from this there will be coming support for eslint.config.cjs and eslint.config.mjs on the next major release for ESLint: https://github.com/eslint/eslint/pull/17909

diegotsutsumi commented 4 months ago

Is there any current workaround for using eslint.config.js and have lsp-mode work for eslint backend?

diegotsutsumi commented 4 months ago

As of today vscode-eslint is in version 2.4.4, this repository (lsp-mode) is using version 2.2.2 , it could be that an upgrade here solves the issue.

I can't upgrade it directly cause it's pulling from a compiled version from a non-official binary repo. I tried to hack an upgrade but spacemacs wouldn't recognize it.

Artawower commented 4 months ago

Were you able to find some sort of workaround?

ovistoica commented 2 months ago

This is fixed by https://github.com/emacs-lsp/lsp-mode/pull/4489

As a workaround until that is merged, you can use the eslint server from your local VSCode:

(use-package lsp-eslint
  :demand t
  :after lsp-mode
  :config
  (setq lsp-eslint-server-command `("node"
                                    "~/.vscode/extensions/dbaeumer.vscode-eslint-3.0.10/server/out/eslintServer.js"
                                    "--stdio")))

This requires VSCode with Eslint extension installed locally

Another option is to change the download URL for the server

(setq lsp-eslint-download-url "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/dbaeumer/vsextensions/vscode-eslint/3.0.10/vspackage") ;; latest VSCode eslint extension from marketplace

Then M-x lsp-install-server choose eslint