How to disable Rule: one-line in TSLint
Asked Answered
M

1

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

Gives

[tslint] misplaced opening brace

.

And if I use the opening braces in same line of function, it doesn't give me warning like

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

This rule is called "one-line" rule And how to configure it in TSLint to handle first type of braces style

Thanks in advance

Minimum answered 11/12, 2018 at 13:47 Comment(0)
M
10

If you want to globally turn of Goto {ProjectDirectoty}/tslint.json and add "one-line" : false in rules

One-line has 5 sub rules as "check-catch", "check-finally", "check-else", "check-open-brace", "check-whitespace". You can understand it from name, like for catch you should or not write opening braces in same or next line.

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

}

If you want to turn off only specific subrule, use something like this

"one-line": [true, "check-catch", "check-finally", "check-else"]

It will turn on for these 3 rules and off for other 2 rules

And if you want to disable in a particular file

/* tslint:disable:rule1 rule2 rule3... */ in that file
Minimum answered 12/12, 2018 at 12:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.