I'm currently setting up my Neovim's Native LSP working environment, and I have a question about JS/TS linter.
What is the difference between tsserver and eslint as a linter?
I know that tsserver is a language-server that comprehensively supports features like auto-completion and go-to-definition, and eslint lints coding styles (e.g. airbnb style).
But if I turn off eslint's code-format-linting feature (e.g. when using prettier together), is there any difference with eslint for linting?
Edit:
I confused diagnostics with linter. What I wanted to ask was :
"What's the difference between tsserve and eslint for diagnostic feature?"
CodePudding user response:
Initially you need to write a specific VSCode extension to do linting, using the diagnostics related VSCode API. That's when TSLint or ESLint extension came out.
But language servers are naturally the central source of diagnostics themselves as they compile the code to AST, so diagnostics API is also available there.
In your case, both tools can tell what might be wrong in your code and you can enable both or disable one of them. It's just a matter of which tool you feel better and reports more issues that you are interested in. They should have many overlaps while a few minor differences in issue catelog.
CodePudding user response:
Generally speaking:
tserver
is a service that runs TypeScript in the background and can respond to compilation commands.
TypeScript itself is not a linter but a compiler that is also capable of tracking down type errors and very few generic code problems.
eslint
is a JavaScript linter that find problems in your code.
Typically you use TypeScript to specifically track down type errors and eslint for all other possible problems or stylistic conventions in your code.