简体   繁体   English

tsserver 和 eslint 作为 linter 有什么区别?

[英]What's the difference between tsserver and eslint as a linter?

I'm currently setting up my Neovim's Native LSP working environment, and I have a question about JS/TS linter.我目前正在设置我的 Neovim 的 Native LSP 工作环境,并且我有一个关于 JS/TS linter 的问题。

What is the difference between tsserver and eslint as a linter? tsserver 和 eslint作为 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 (eg airbnb style).我知道 tsserver 是一个语言服务器,它全面支持自动完成和转到定义等功能,以及编码 styles(例如 airbnb 样式)的 eslint lints。

But if I turn off eslint's code-format-linting feature (eg when using prettier together), is there any difference with eslint for linting?但是如果我关闭 eslint 的 code-format-linting 功能(例如一起使用 prettier 时),与 eslint 的 linting 有什么区别吗?

Edit:编辑:

I confused diagnostics with linter.我将诊断与 linter 混淆了。 What I wanted to ask was:我想问的是:

"What's the difference between tsserve and eslint for diagnostic feature?" “用于诊断功能的 tsserve 和 eslint 有什么区别?”

Initially you need to write a specific VSCode extension to do linting, using the diagnostics related VSCode API .最初,您需要使用与诊断相关的VSCode API 编写特定的 VSCode 扩展来进行 linting That's when TSLint or ESLint extension came out.那是 TSLint 或 ESLint 扩展出现的时候。

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.但是语言服务器自然是诊断本身的中心来源,因为它们将代码编译为 AST,因此诊断 API也可用。

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.这只是您感觉更好并报告更多您感兴趣的问题的工具的问题。它们应该有很多重叠,而问题目录中的一些细微差别。

Generally speaking:通常来说,一般来说:

tserver is a service that runs TypeScript in the background and can respond to compilation commands. tserver是一个后台运行TypeScript的服务,可以响应编译命令。 TypeScript itself is not a linter but a compiler that is also capable of tracking down type errors and very few generic code problems. TypeScript 本身不是一个 linter,而是一个能够追踪类型错误和极少通用代码问题的编译器。 eslint is a JavaScript linter that find problems in your code. eslint是一个 JavaScript linter,可以在您的代码中发现问题。

Typically you use TypeScript to specifically track down type errors and eslint for all other possible problems or stylistic conventions in your code.通常,您使用 TypeScript 专门跟踪代码中的所有其他可能问题或风格约定的类型错误和 eslint。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM