- 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.
推薦閱讀
- Drupal 8 Blueprints
- SQL Server 2012數(shù)據(jù)庫技術(shù)及應(yīng)用(微課版·第5版)
- R語言編程指南
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- Learn Scala Programming
- HTML5游戲開發(fā)案例教程
- Linux操作系統(tǒng)基礎(chǔ)案例教程
- 微信小程序全棧開發(fā)技術(shù)與實(shí)戰(zhàn)(微課版)
- FPGA嵌入式項(xiàng)目開發(fā)實(shí)戰(zhàn)
- Oracle實(shí)用教程
- Django Design Patterns and Best Practices
- Mastering Android Studio 3
- Python Linux系統(tǒng)管理與自動化運(yùn)維
- VMware vSphere Design Essentials
- Enterprise Application Architecture with .NET Core