crush
crush

Reputation: 17023

Is it possible to configure TSLint in Visual Studio 2015?

TSLint is complaining that single-quotes should be double-quotes. Our team prefers to use single-quotes to wrap string literals.

I see that TSLint is configurable to set the mode to single-quote, but I cannot find a way to set these rules in Visual Studio 2015.

In Options, I found a couple of TSLint options under Text Editor > TypeScript > TSLint:

Obviously, these aren't the settings for which I'm looking...

Has anyone found a way to configure the TSLint rules in Visual Studio 2015, or is this something we just have to hope they add in the near future?


This solution: Setup TSLint in Visual Studio 2015

Seems to just be about adding TSLint to Visual Studio 2015 if it doesn't already exist. That's not what I'm looking for either.

Upvotes: 14

Views: 4664

Answers (4)

Martin Randall
Martin Randall

Reputation: 328

If you're still having problems, try upgrading to the latest version of TypeScript for Visual Studio 2015 before adding tslint.json to your project root.

I looked at this in late 2016, with Wanton's approach of adding tslint.json to the project root, and for whatever reason I couldn't get it to work. Possibly because I was using tslint-microsoft-contrib for some rules. Wanton's advice around UTF encoding and line endings did not help. Upgrading to the April 2017 version of TypeScript for Visual Studio seemed to fix it.

That said, I could always get it working using the Tools > Web Code Analysis > Edit TSLint Settings (tslint.json) option from Clark, but that's not ideal for me, because it's a machine-level setting, not a project-level setting. Still, this may be a good enough solution for you.

Another variable to check is the settings at Tools -> Options -> External Web Tools. You may need to place .\node_modules\.bin higher than $(VSINSTALLDIR)\Web\External, depending on how you are using tslint.

Upvotes: 2

Clark
Clark

Reputation: 2678

Tools > Web Code Analysis > Edit TSLint Settings (tslint.json)

Upvotes: 13

Wanton
Wanton

Reputation: 840

Add tslint.json to your project root and configure it with that. I had hard time to get this to work. Seems that there is a bug somewhere and tslint.json only works when it has Windows line endings. So make sure you have Windows line endings \r\n and not UNIX \n.

Update: First I thought it was line endings that was causing this problem. But it's actually tslint.json files encoding. If encoding is shown as UTF-8-BOM in Notepad++ the file refuses to work. If you change encoding to UTF-8 it starts to work.

Upvotes: 3

Andrew
Andrew

Reputation: 3332

If you're using tslint in Visual Studio using Web Analyzer then it looks like you can edit the tslint.json configuration file directly from the Web Analyzer's Tools menu.

Look at the above link in the Configuration section for the "Edit TSLint settings (tslint.json)" option.

Upvotes: 1

Related Questions