- Learn React with TypeScript 3
- Carl Rippon
- 173字
- 2021-06-10 19:16:40
Built-in rules
tslint has a handy collection of built-in rulesets that can be used. We can use these by specifying the ruleset name in the extends field. We can use multiple rulesets by putting all their names in the array:
- Let's adopt the opinionated set of rules that tslint ships with, called "tslint:recommended". So, in our tslint.json file, let's remove the rules field and add an extends field, as follows:
{
"extends": ["tslint:recommended"]
}
We immediately get lint errors when tslint.json is saved. The error is complaining about the lack of an I prefix on our Product interface. The logic behind the rule is that, while reading code, if a type starts with an I, we immediately know that it is an interface.
- Let's pretend that this rule isn't valuable to us. We can override this rule from "tslint:recommended" in the "rules" field. The rule is called "interface-name". So, let's override this to false:
{
"extends": ["tslint:recommended"],
"rules": {
"interface-name": false
}
}
When tslint.json is saved, the linting errors immediately go away.
推薦閱讀
- Getting Started with Citrix XenApp? 7.6
- Qt 5 and OpenCV 4 Computer Vision Projects
- C語言程序設計(第2 版)
- JMeter 性能測試實戰(第2版)
- Visual FoxPro 程序設計
- Java程序員面試算法寶典
- 自然語言處理Python進階
- 區塊鏈技術與應用
- Java面向對象程序設計
- JavaScript程序設計(第2版)
- Creating Data Stories with Tableau Public
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- 跟戴銘學iOS編程:理順核心知識點
- Angular Design Patterns
- Java程序設計