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

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.

主站蜘蛛池模板: 安泽县| 龙里县| 三亚市| 桂林市| 射阳县| 博乐市| 独山县| 二连浩特市| 汝州市| 长治市| 黄陵县| 呼伦贝尔市| 多伦县| 肇庆市| 屯留县| 垣曲县| 关岭| 无锡市| 莒南县| 饶阳县| 绥芬河市| 博白县| 丰镇市| 金溪县| 驻马店市| 万山特区| 三门峡市| 梓潼县| 白水县| 石屏县| 保山市| 远安县| 桂阳县| 屯门区| 新闻| 永仁县| 萍乡市| 富阳市| 通州区| 佛冈县| 黄浦区|