Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TSLint in Visual Studio 2015/2017?

My organization uses TSLint pretty heavily for quality-checking our Typescript code, and it provides a valuable service to us! However, we use Visual Studio 2015 & 2017 as our main IDE and the only way to get the linting results it to run a gulp/grunt task which prints the output to the Task Runner Explorer console. It works, but it's slow and not the best development experience.

In smaller projects on my own I've used VSCode, which has a fantastic TSLint plugin that highlights linting violations as you make them, and provides access to the auto-fixers that some TSLint rules have. Like this:

VSCode TSLint example

Is it possible to get this same functionality in Visual Studio 2015/2017? The immediate feedback is a life saver when writing TypeScript code.

like image 496
FiniteLooper Avatar asked Apr 10 '17 12:04

FiniteLooper


2 Answers

As @Hermann Gruber has mentioned, in Visual Studio 2015 Mads Kristensen's Web Analyzer extension provides support for TSLint of the kind you require.

For Visual Studio 2017 and 2019 I have now personally upgraded Mads' extension, and rebranded it as 'TypeScript Analyzer' as it only supports TSLint. It's available in Visual Studio's Extensions and Updates Gallery under 'TypeScript Analyzer'.

like image 84
Rich N Avatar answered Oct 22 '22 06:10

Rich N


This is something I coded in a day or two (note that I haven't worked with C# for a few years):

https://github.com/vladeck/TSLint

It is a start of (hopefully) worth-wile Visual Studio 2017 extension that can mark .ts code withing the editor, based on the installed tslint and tslint.json configuration.

It is not published on the marketplace yet (a lot more coding to do), but you can download and build it yourself. Give it a try, If you have the time. The more people try it out, the more I will have data needed to make it worth-wile.

like image 22
vladeck Avatar answered Oct 22 '22 04:10

vladeck