官术网_书友最值得收藏!

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:

  1. 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.

  1. 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.

主站蜘蛛池模板: 乌苏市| 瓮安县| 甘洛县| 龙岩市| 巩留县| 喀什市| 华宁县| 江安县| 邹城市| 卫辉市| 昌邑市| 抚松县| 沁源县| 勃利县| 离岛区| 高雄市| 茂名市| 濮阳市| 长泰县| 彰化县| 明溪县| 银川市| 宁都县| 永年县| 宣威市| 如皋市| 日土县| 黑河市| 沂源县| 手游| 宁国市| 东安县| 吉木乃县| 锦屏县| 棋牌| 鄢陵县| 澎湖县| 皋兰县| 申扎县| 社会| 玉龙|