TSLint Config in VS Code
Asked Answered
S

1

5

I'm trying to configure the max line length (among other settings) for TS Lint in VS code but no matter what changes I make it doesn't 'take'.

So, the first strange thing is that VS code's TS Lint error for max line length says I've exceeded the 140 character limit but in the various config files I've found it only ever mentions 120 characters as the default.

I've changed this to 200 characters, disabled / enabled the extension but still get the 140 character warning. Does anyone know where and how to configure this setting? The documentation online is clear enough but I don't appear to have a tslint.json file and within the node_modules => tslint => lib => rules folder the setting is 120 and changing it makes no difference.

Selmaselman answered 12/2, 2018 at 10:55 Comment(2)
Is your question regarding the tslint package or the corresponding vscode extension?Armoured
It's regarding the VS Code extension but perhaps the answer applies to the package as well? I'm unfamiliar with TSLint (only having used it through VS Code) so maybe need to clarify in my question?Selmaselman
A
10

Edit 2020-09-30

Microsoft deprectaded the old plugin and released a newer, completely rewritten version with additional features here.

For the new plugin the setting "tslint.enable": true does not exists and is not needed anymore.

Original Answer

You need to create a tslint.json (in your workspace root) and set something like this to disable the maximum line length:

{    
    "defaultSeverity": "error",
    "extends": [
        "tslint:recommended"
    ],
    "jsRules": {},
    "rules": {
        "max-line-length": [false]
    },
    "rulesDirectory": []
}

Furthermore, ensure that the following options are set in the in the vscode user settings (settings.json):

"tslint.configFile": "./path/to/tslint/relative/from/workspaceroot/tslint.json",
"tslint.enable": true

The tslint.configFile option can be empty if the file is in the root directory of your workspace.
Further rules can be found here.

Armoured answered 12/2, 2018 at 15:20 Comment(5)
Perfect thank you! Is it just me or is this not clear in the documentation?Selmaselman
Have you found the tslint homepage? When you follow the Quickstart and run tslint --init helps you to create your first inital tslint.json file.Armoured
Thanks, this is the link the VS code brings you to, which is less clear. github.com/palantir/tslint but I should have spent longer looking.Selmaselman
tslint.enable seems no longer to exist as a setttings property (Sept 2020, vscode 1.48.2)Ebner
You are right this setting only exists on the deprecated version of the pluginArmoured

© 2022 - 2024 — McMap. All rights reserved.