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

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.

主站蜘蛛池模板: 科技| 罗源县| 连城县| 南陵县| 鄂托克前旗| 东莞市| 龙门县| 当雄县| 铜川市| 枝江市| 永新县| 西乌珠穆沁旗| 彭泽县| 宣化县| 伊宁市| 高密市| 新和县| 沂水县| 卓资县| 江北区| 铜陵市| 咸阳市| 阳原县| 富锦市| 桑日县| 丹东市| 繁昌县| 淮阳县| 伊吾县| 同江市| 上高县| 龙泉市| 边坝县| 江安县| 梁河县| 景宁| 青阳县| 颍上县| 鄂州市| 梁山县| 连云港市|