8.1.tslint
7.1.TSLint
一 概述
TSLint是一个可扩展的静态分析工具,用于检查TypeScript代码的可读性,可维护性和功能性错误.(类似于ESLint于javascript)但是该笔记主要针对angular中的tslint.json文件.
个人使用体验:能提示出引入但未使用的包,还是可以.
3 常识
3.1 angular中tslint.json的提示说明
括号中的内容就是tslint.json的配置名称,可以很方便的定位
三 基础
1 配置说明
1.1 默认只支持单引号
quotemark
1.2 默认的缩进
indent:可选"tabs"或者"spaces"
六 问题
1 已解决
1.1 while statements must be braced (curly)
while 语句必须要有括号
1.2 comment must start with a space (comment-format)
注释的双杠后面必须要有一个空格
1.3 file should end with a newline (eofline)
文件应该以空行结尾
1.4 Declaration of instance field not allowed after declaration of instance method. Instead, this should come at the beginning of the class/interface. (member-ordering)
类中成员的顺序需要按照规则来
1.5 Type string trivially inferred from a string literal, remove type annotation (no-inferrable-types)
变量已经初始为string字面量了,即变量的类型已经能够推理出来,就不再需要类型声明了.
1.6 Exceeds maximum line length of 140 (max-line-length)
1.7 Class name must be in pascal case (class-name)
1.8 == should be === (triple-equals)
1.9 trailing whitespace (no-trailing-whitespace)
末尾不应该有空格
2 未解决
如何禁用所有tslint.json
Last updated
Was this helpful?