如何禁用规则:TSLint中的一行

时间:2018-12-11 13:47:42

标签: tslint

 clearFile()
 {
      (<HTMLInputElement>document.getElementById('uploadFile')).value = "";
 }

给予

[tslint] misplaced opening brace

如果我在同一行功能中使用了开括号,它不会像这样给我警告

clearFile(){
      (<HTMLInputElement>document.getElementById('uploadFile')).value = "";
 }

此规则称为“单行”规则 以及如何在TSLint中配置它以处理第一类花括号样式

预先感谢

1 个答案:

答案 0 :(得分:2)

如果要全局转到Goto {ProjectDirectoty} /tslint.json并添加“单行”:规则中为false

单行有5个子规则,例如“ check-catch”,“ check-finally”,“ check-else”,“ check-open-brace”,“ check-whitespace”。您可以从名称中了解它,例如要抓住,您应该在同一行还是下一行中写上开括号。

 var storedValue = "Redis TimeStamp : " + DateTime.Now.ToString("s");
            HttpContext.Session.SetString("TestValue", storedValue);
            HttpContext.Session.CommitAsync();

}

如果您只想关闭特定子规则,请使用类似的

{
"extends": "../tslint.json",
"rules": {
    "one-line" : false,
    "directive-selector": [
        true,
        "attribute",
        "app",
        "camelCase"
    ],
    "component-selector": [
        true,
        "element",
        "app",
        "kebab-case"
    ]
}

这3个规则将打开,其他2个规则将关闭

如果要禁用特定文件

"one-line": [true, "check-catch", "check-finally", "check-else"]
相关问题