syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.66k stars 4.89k forks source link

Typescript layer: No ESLint configuration found in project after explicitly setting `exec-path` with project path to ESLint #16307

Closed noelweichbrodt closed 1 month ago

noelweichbrodt commented 6 months ago
LSP :: Connected to [eslint:71271/starting /Users/noel/w/project].
LSP :: eslint:71271 initialized successfully in folders: (/Users/noel/w/project)
LSP :: Error from the Language Server: Request textDocument/codeAction failed with message: No ESLint configuration found in /Users/noel/w/project/pages/api/auth. (Internal Error)

I found https://github.com/syl20bnr/spacemacs/issues/10131, which seemed like it directly addressed my issue, so I followed the solution there to utilize add-node-modules-path to load the project's local ESLint, however the error persisted. I tried explicitly setting (setq exec-path (append '("/Users/noel/w/project/node_modules/.bin") exec-path)), but the error persisted. Now I'm out of ideas 😓

Here's the flycheck-verify-setup:

Syntax checkers for buffer login.ts in typescript-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that could run if selected:

  typescript-tslint  select
    - may enable:         yes
    - executable:         Found at /usr/local/bin/tslint
    - configuration file: Not found

Checkers that are compatible with this mode, but will not run until properly configured:

  javascript-eslint (automatically disabled) reset
    - may enable:  no
    - executable:  Not found
    - config file: missing or incorrect

Flycheck Mode is enabled. Use M-m u M-m e d to enable disabled checkers.

--------------------

Flycheck version: 20240307.2106
Emacs version:    29.2
System:           aarch64-apple-darwin23.3.0
Window system:    ns

And for context, my config:

dotspacemacs-configuration-layers:

     (typescript :variables
                 typescript-fmt-on-save t
                 typescript-fmt-tool 'prettier
                 typescript-linter 'eslint)

user-config:

  (eval-after-load 'typescript-mode
    '(add-hook 'typescript-mode-hook #'add-node-modules-path))

Finally, for the paranoid, there is in fact ESLint installed in the project:

% /Users/noel/w/project/node_modules/.bin/eslint --version
v8.57.0

…and in javascript mode flycheck can find it:

Syntax checkers for buffer eslint.config.js in js2-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that could run if selected:

  javascript-eslint  select
    - may enable:  yes
    - executable:  Found at /Users/noel/w/project/node_modules/.bin/eslint
    - config file: found

  javascript-standard  select
    - may enable: yes
    - executable: Found at /usr/local/bin/standard

Checkers that are compatible with this mode, but will not run until properly configured:

  javascript-jshint (automatically disabled) reset
    - may enable:         no
    - executable:         Not found
    - configuration file: Not found

Flycheck Mode is enabled. Use M-m u M-m e d to enable disabled checkers.

--------------------

Flycheck version: 20240307.2106
Emacs version:    29.2
System:           aarch64-apple-darwin23.3.0
Window system:    ns
noelweichbrodt commented 6 months ago

Inexplicable update: after restarting (SPC q r) a couple of times to disable typescript layer entirely and then put it back in, I'm now seeing this in tsx files:

Syntax checkers for buffer Login.tsx in typescript-tsx-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that could run if selected:

  javascript-eslint  select
    - may enable:  yes
    - executable:  Found at /Users/noel/w/project/node_modules/.bin/eslint
    - config file: found

Flycheck Mode is enabled. Use M-m u M-m e d to enable disabled checkers.

--------------------

Flycheck version: 20240307.2106
Emacs version:    29.2
System:           aarch64-apple-darwin23.3.0
Window system:    ns

So of course, I select javascript-eslint:

Syntax checkers for buffer LoginForm.tsx in typescript-tsx-mode:

First checker to run:

  javascript-eslint (explicitly selected)
    - may enable:  yes
    - executable:  Found at /Users/noel/w/project/node_modules/.bin/eslint
    - config file: found

Checkers that could run if selected:

  lsp  select
    - may enable: yes
    - may run:    t

Flycheck Mode is enabled. Use M-m u M-m e d to enable disabled checkers.

--------------------

Flycheck version: 20240307.2106
Emacs version:    29.2
System:           aarch64-apple-darwin23.3.0
Window system:    ns

However, any flycheck action still shows the same error as above: LSP :: Error from the Language Server: Request textDocument/codeAction failed with message: No ESLint configuration found in /Users/noel/w/project/app/login/components. (Internal Error)

And of course, if I remove my explicit setq exec-path for the project, flycheck is not longer able to find the eslint executable or project config:

Syntax checkers for buffer LoginForm.tsx in typescript-tsx-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that are compatible with this mode, but will not run until properly configured:

  javascript-eslint (automatically disabled) reset
    - may enable:  no
    - executable:  Not found
    - config file: missing or incorrect

Flycheck Mode is enabled. Use M-m u M-m e d to enable disabled checkers.

--------------------

Flycheck version: 20240307.2106
Emacs version:    29.2
System:           aarch64-apple-darwin23.3.0
Window system:    ns
diegotsutsumi commented 4 months ago

Might be related to this

https://github.com/emacs-lsp/lsp-mode/issues/4341

smile13241324 commented 3 months ago

I am not working with typescript but judging from the output of flycheck I assume you have configured the local flycheck checker for eslint. But that's not used at all as your lsp server is calling flycheck to do the linting.

Therefore you need to check the lsp mode documentation how to tell your lsp server where to look for eslint instead.