Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TSLint Config in VS Code

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.

like image 519
Full Time Skeleton Avatar asked Feb 12 '18 10:02

Full Time Skeleton


People also ask

How do I run a Tslint command line?

tslint accepts the following command-line options: -c, --config: The location of the configuration file that tslint will use to determine which rules are activated and what options to provide to the rules. If no option is specified, the config file named tslint. json is used, so long as it exists in the path.

Where is the settings json file for Vscode?

Depending on your platform, the user settings file is located here: Windows %APPDATA%\Code\User\settings.json. macOS $HOME/Library/Application\ Support/Code/User/settings.json. Linux $HOME/.config/Code/User/settings.json.

Is Tslint obsolete?

TSLint has been the recommended linter in the past but now TSLint is deprecated and ESLint is taking over its duties.


1 Answers

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.

like image 155
HaaLeo Avatar answered Oct 24 '22 09:10

HaaLeo