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

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.

主站蜘蛛池模板: 双峰县| 洞口县| 满城县| 繁峙县| 阳东县| 长顺县| 渭南市| 渭南市| 兴安盟| 郎溪县| 莱芜市| 历史| 呼和浩特市| 区。| 工布江达县| 墨江| 阳谷县| 西平县| 鹤峰县| 林州市| 新化县| 大同县| 德阳市| 寿宁县| 景东| 益阳市| 阳原县| 红河县| 乌拉特后旗| 邢台市| 双柏县| 景洪市| 宁国市| 西藏| 信阳市| 柳林县| 普宁市| 堆龙德庆县| 虎林市| 蕉岭县| 嘉黎县|