Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use TSLint in VS Code?

I have installed TSLint in VSCode and created a tslint.json file next to tsconfig.json. But TSLint is not working. For example, I added "curly": true to tslint.json, but when I write a if statement without curly braces, VS Code doesn't give any warning. What does this extension do?

enter image description here

like image 917
Zen Avatar asked Apr 22 '16 05:04

Zen


People also ask

How do I add a Tslint to my project?

Installing TSLint on an existing projectThe first line installs tslint as a devDependency. The second line run tslint using yarn, this way I don't have to write ./node_modules/. bin/tslint . As I have an existing TypeScript project, I'll point tslint to the project configuration file.

What is the use of Tslint?

TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.


2 Answers

On a new machine, I installed VS Code tslint extension before installing tslint itself (via npm), and nothing helped to make it work other than disabling and re-enabling the extension.

enter image description here

like image 152
V.B. Avatar answered Sep 23 '22 15:09

V.B.


The vscode-tslint extension currently crashes silently when it encounters an invalid config-option. In my case, it was the no-trailing-comma rule which has to be changed to trailing-comma.

More info here: https://github.com/Microsoft/vscode-tslint/issues/66

like image 23
opus131 Avatar answered Sep 21 '22 15:09

opus131