File tree Expand file tree Collapse file tree 3 files changed +2
-18
lines changed Expand file tree Collapse file tree 3 files changed +2
-18
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ console.log(`My name is ${myName}`)
81
81
82
82
## 应该使用哪种代码检查工具
83
83
84
- TSLint 与 ESLint 作为检查 TypeScript 代码的工具,各自都有自己的优点 :
84
+ TSLint 与 ESLint 作为检查 TypeScript 代码的工具,各自有各自的优点 :
85
85
86
86
TSLint 的优点:
87
87
@@ -127,23 +127,7 @@ ESLint 可以检测出来以上代码的函数参数超过了 7 个(需要开
127
127
128
128
那么到底该使用哪种代码检测工具呢?经过一些实践,我建议可以按照以下流程决定:
129
129
130
- ``` ts
131
- if (' 项目正在由 js 改造为 ts 的过程中' ) {
132
- if (' 原 js 项目使用了 eslint' ) {
133
- if (' 将会长时间处于 js 与 ts 共存的状态' ) {
134
- // 由于一个项目中无法针对不同后缀的文件使用不同的 eslint 配置
135
- // 故新 ts 文件只能使用 tslint 检查,老 js 文件保持使用 eslint 检查
136
- return ' tslint' & ' eslint' ;
137
- } else if (' 能够快速的将所有文件都重构为 ts' ) {
138
- // 使原有 eslint 支持对 ts 文件的检查
139
- return ' eslint' ;
140
- }
141
- }
142
- }
143
- // TSLint 利用类型系统增强的一些检查大多是无关痛痒的,或者是可以在 tsc 编译过程中检查出来的
144
- // ESLint 生态环境更好,虽然现在还存在一些 bug,但是应该积极使用,推动它的发展
145
- return ' eslint' ;
146
- ```
130
+ ![ 流程图:选择 ESLint 还是 TSLint] ( ../assets/eslint-or-tslint-process.png )
147
131
148
132
## 在 TypeScript 中使用 ESLint
149
133
You can’t perform that action at this time.
0 commit comments