Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64d34fa

Browse files
committed
更新 lint 文案
1 parent 12e5fd0 commit 64d34fa

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

engineering/lint.md

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ module.exports = {
128128

129129
### 检查一个 ts 文件
130130

131-
创建了配置文件之后,我们来创建一个 ts 文件看看是否能用 ESLint 去检查它了
131+
创建了配置文件之后,我们来创建一个 ts 文件看看是否能用 ESLint 去检查它
132132

133133
创建一个新文件 `index.ts`,将以下内容复制进去:
134134

@@ -185,21 +185,6 @@ type Foo = {};
185185

186186
此时执行 `npm run eslint` 即会检查 `src` 目录下的所有 `.ts` 后缀的文件。
187187

188-
### 自动修复错误
189-
190-
ESLint 的大部分规则都支持自动修复错误,我们可以配置一个 npm script:
191-
192-
```json
193-
{
194-
"scripts": {
195-
"eslint": "eslint src --ext .ts",
196-
"eslint:fix": "eslint src --fix --ext .ts"
197-
}
198-
}
199-
```
200-
201-
执行 `npm run eslint:fix` 即会在执行 ESLint 检查时自动修复错误。
202-
203188
### 在 VSCode 中集成 ESLint 检查
204189

205190
在编辑器中集成 ESLint 检查,可以在开发过程中就发现错误,甚至可以在保存时自动修复错误,极大的增加了开发效率。
@@ -332,7 +317,7 @@ module.exports = {
332317

333318
ESLint 原生的规则和 `@typescript-eslint/eslint-plugin` 的规则太多了,而且原生的规则有一些在 TypeScript 中支持的不好,需要禁用掉。
334319

335-
这里我推荐使用 [AlloyTeam ESLint 规则中的 TypeScript 版本](https://github.com/AlloyTeam/eslint-config-alloy#typescript),它已经为我们提供了一套完善的配置规则。
320+
这里我推荐使用 [AlloyTeam ESLint 规则中的 TypeScript 版本](https://github.com/AlloyTeam/eslint-config-alloy#typescript),它已经为我们提供了一套完善的配置规则,并且与 Prettier 是完全兼容的(eslint-config-alloy 不包含任何代码格式的规则,代码格式的问题交给更专业的 Prettier 去处理)
336321

337322
安装:
338323

@@ -387,8 +372,7 @@ npm install --save-dev eslint-plugin-react
387372
```json
388373
{
389374
"scripts": {
390-
"eslint": "eslint src --ext .ts,.tsx",
391-
"eslint:fix": "eslint src --fix --ext .ts,.tsx"
375+
"eslint": "eslint src --ext .ts,.tsx"
392376
}
393377
}
394378
```

0 commit comments

Comments
 (0)