helix icon indicating copy to clipboard operation
helix copied to clipboard

vscode-eslint-language-server does not work

Open wparsonsheins-globality opened this issue 2 years ago • 3 comments

Summary

The eslint language server expects to be passed a workingDirectory but null was given.

Reproduction Steps

I tried this:

  1. hx
  2. Open a tsx file

I expected this to happen: The language server could spawn

Instead, this happened: The language server did not spawn

Helix log

~/.cache/helix/helix.log
2022-08-23T16:49:42.652 helix_lsp::transport [ERROR] err <- "(node:12369) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'workingDirectory' of null\n"

Platform

macOS

Terminal Emulator

Iterm2-3.4.16

Helix Version

helix 22.05

wparsonsheins-globality avatar Aug 23 '22 15:08 wparsonsheins-globality

workingDirectory is not part of the LSP spec - this server is expecting it as a configuration option. You can provide configuration options with the config option in languages.toml like here

the-mikedavis avatar Aug 23 '22 16:08 the-mikedavis

I tried adding the config property but the logs show workingDirectory is still null.

[[language]]
name = "tsx"
scope = "source.tsx"
injection-regex = "^(tsx)$" # |typescript
file-types = ["tsx"]
roots = []
language-server = { command = "vscode-eslint-language-server", args = ["--stdio"], language-id = "typescriptreact" }
indent = { tab-width = 4, unit = "  " }
config = { "workingDirectory" = "./" }

wparsonsheins-globality avatar Aug 24 '22 11:08 wparsonsheins-globality

Experiencing the same issue, I have been digging within the vscode-eslint-language-server code and logged some stuff, it seems that no configuration is found for the workspace despite setting the config property in the TOML file.

Ganitzsh avatar Sep 17 '22 08:09 Ganitzsh

Here is a minimal working configuration based on lspconfig but it requires a fix present in #2507:

[language-server.eslint]
command = "vscode-eslint-language-server"
args = ["--stdio"]

[language-server.eslint.config]
validate = "on"
experimental = { useFlatConfig = false }
rulesCustomizations = []
run = "onType"
problems = { shortenToSingleLine = false }
nodePath = ""

With these settings the eslint language server runs when opening a file without errors. Additional options like codeAction can be enabled.

LEI avatar Feb 22 '23 13:02 LEI

It seems that there is an additional problem. It seems that vscode-eslint-language-server does not work well for monorepos on it's own. When you have eslintConfig setup in root's package.json, launching eslint in sub-package won't find the root's config. Since vscode-eslint-language-server stops looking for workspace directory as soon it finds any of project's folder indicators such as "package.json". "eslintignore" or "eslintrc". It can be seen in the source code here: https://github.com/microsoft/vscode-eslint/blob/cbb35d03497bb39043033defbad7fd80b2a89698/server/src/eslintServer.ts#L1093

Vscode and vim tend to work cos they provide some hacky work arounds to find workspace directory. In helix, without plugin management, I am not sure what can be done (apart of manually setting workingDirectory path to workspace's directory

JeviScript avatar Nov 06 '23 16:11 JeviScript

@JeviScript I am working in a monorepo as well and having the same issue. Did you find a better solution to this problem in the meantime?

th7mo avatar Jan 22 '24 19:01 th7mo

@JeviScript I am working in a monorepo as well and having the same issue. Did you find a better solution to this problem in the meantime?

I switched to vim xD

JeviScript avatar Jan 22 '24 19:01 JeviScript