Skip to main content

TSLint 怎么样?


TSLint 是一个相当于 ESLint 的 linter,专门为直接在 TypeScript 代码上工作而编写。

英:TSLint was a linter equivalent to ESLint that was written specifically to work directly on TypeScript code.

TSLint 已弃用,你应该使用 typescript-eslint

英:TSLint is deprecated and you should use typescript-eslint instead.

从 TSLint 迁移到 ESLint

将 TSLint 配置转换为等效 ESLint 配置的标准工具是 tslint-to-eslint-config。 如果你仍在使用 TSLint,我们强烈建议你使用此工具进行切换。

英:The standard tool to convert a TSLint configuration to the equivalent ESLint configuration is tslint-to-eslint-config. If you are still using TSLint, we strongly recommend you use this tool to switch.

你可以查看 替代品清单,了解 TSLint 规则与此包中规则的比较的最新概述。

英:You can look at the alternatives list for an up to date overview of how TSLint rules compare to the ones in this package.

如果你绝对必须在 ESLint 中使用 TSLint,那么还有最终的后备选项,即在过渡期间同时使用两个 linter。 对于此选项,请查看 @typescript-eslint/eslint-plugin-tslint

英:There is also the ultimate fallback option of using both linters together for a while during your transition if you absolutely have to by using TSLint within ESLint. For this option, check out @typescript-eslint/eslint-plugin-tslint.

为什么弃用 TSLint?

TSLint 相对于 ESLint 的优势之一是无需使用工具来协调 JavaScript 和 TypeScript 语法之间的差异。 不幸的是,这意味着 TSLint 无法重用之前在 ESLint 周围的 JavaScript 生态系统中所做的任何工作。 TSLint 必须重新实现从编辑器扩展到自动修复再到规则的所有内容。

英:One advantage of TSLint over ESLint was that there was no tooling required to reconcile differences between JavaScript and TypeScript syntax. Unfortunately, that meant TSLint couldn't reuse any of the previous work which has been done in the JavaScript ecosystem around ESLint. TSLint had to reimplement everything from editor extensions to auto-fixing to rules.

TSLint 的支持者于 2019 年宣布 他们将弃用 TSLint,转而支持 typescript-eslint,以造福社区。 你可以在这里阅读更多相关内容: https://medium.com/palantir/tslint-in-2019-1a144c2317a9。

英:TSLint's backers announced in 2019 that they would be deprecating TSLint in favor of supporting typescript-eslint in order to benefit the community. You can read more about that here: https://medium.com/palantir/tslint-in-2019-1a144c2317a9.

TypeScript 团队还将 TypeScript 代码库从 TSLint 迁移到了 typescript-eslint,他们一直是这个项目的支持者。 更多详情请参见 https://github.com/microsoft/TypeScript/issues/30553。

英:The TypeScript team also migrated the TypeScript codebase from TSLint to typescript-eslint, and they have been supporters of this project. See more details at https://github.com/microsoft/TypeScript/issues/30553.