|

我们在做 angular 项目的时候,在编辑 .ts 文件,我们编码可能不会那么规范,例如:变量的定义、空格、引号等。
我们可以使用如下命令检查项目中产生的warning警告。
C:\project\colors>ng lint
Linting "colors"...
ERROR: C:/project/colors/src/app/app.component.ts:1497:17 - Unnecessarily quoted property 'strength' found.
ERROR: C:/project/colors/src/app/app.component.ts:1497:17 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1517:1 - space indentation expected
ERROR: C:/project/colors/src/app/app.component.ts:1517:6 - Identifier 'a' is never reassigned; use 'const' instead of 'let'.
ERROR: C:/project/colors/src/app/app.component.ts:1517:10 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1518:5 - statements are not aligned
ERROR: C:/project/colors/src/app/app.component.ts:1519:5 - statements are not aligned
ERROR: C:/project/colors/src/app/app.component.ts:1522:25 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1523:1 - space indentation expected
ERROR: C:/project/colors/src/app/app.component.ts:1523:2 - statements are not aligned
ERROR: C:/project/colors/src/app/app.component.ts:1523:4 - missing whitespace
ERROR: C:/project/colors/src/app/app.component.ts:1523:17 - == should be ===
ERROR: C:/project/colors/src/app/app.component.ts:1523:20 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1523:24 - missing whitespace
ERROR: C:/project/colors/src/app/app.component.ts:1524:1 - space indentation expected
ERROR: C:/project/colors/src/app/app.component.ts:1524:15 - " should be '
ERROR: C:/project/colors/src/app/app.component.ts:1525:1 - space indentation expected
Lint errors found in the listed files.
如下图:
如何修复这些警告呢?
命令如下:
能自动修复的错误包括:missing whitespace, Missing semicolon, " should be ', misplaced 'else', file should end with a newline, trailing whitespace, Unnecessary semicolon, Identifier 'XXX' is never reass
使用自动修复警告命令,不一定能修正所有的警告,如果不能自动修正的,需要我们手动修复警告。
|
上一篇:cmd 设置永久环境变量命令下一篇:js 字符串反转
|