Configure tslint with VS 2015 Update 2

2019-02-25 19:25发布

I can't get tslint to work properly in Visual Studio 2015. I should precise that:

  • I have Update 2 installed.
  • I have Web Essentials, but it claims that it doesn't includre linters anymore.
  • I do NOT have Web Analyzers.
  • This is an ASP.NET Core xproj, if that matters.

The linter runs: I can see warnings in my error pane and when I right-click a TS file I have a command "Run Web Code Analysis".

Now I want to configure the rules by adding a tslint.json file in my project (I tried various places). As soon as I add one -- even a copy of the default one from my user profile -- I do get no warning at all.

Using process monitor I can confirm that the linter runs in both cases and that it reads tslint.json from the correct place (my project or my user profile). But even if the file is exactly the same, when it runs from my project there is no result in VS??

1条回答
做个烂人
2楼-- · 2019-02-25 19:53

I had this exact problem. Took hours to find this but you can make tslint.json work in project root if you change line endings from UNIX to Windows/Dos (from \n to \r\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 tile encoding to UTF-8 it starts to work.

查看更多
登录 后发表回答