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

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.

主站蜘蛛池模板: 祁东县| 梨树县| 靖宇县| 新晃| 晴隆县| 岳阳市| 玉树县| 明光市| 佛学| 巴东县| 同江市| 临潭县| 道孚县| 泊头市| 沈丘县| 太原市| 正蓝旗| 溧阳市| 依兰县| 类乌齐县| 岢岚县| 宿松县| 邵阳市| 资阳市| 屏边| 调兵山市| 绵阳市| 广元市| 大邑县| 商河县| 延川县| 丹棱县| 大新县| 舞阳县| 嘉禾县| 奉节县| 阳东县| 灌南县| 鹿泉市| 行唐县| 广元市|