Set up TSLint for VS2017

廉价感情. 提交于 2019-11-29 04:16:46

问题


I have tried to install this plugin: Web Analyzer, but unfortunately it can not be installed in VS 2017. It showed:

VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.

I am wondering whether there is a way to set up tslint in VS or there is any other way to check the syntax?


回答1:


Now that TypeScript has language server plugins support and there's TSLint plugin, another option is available:

  • Install Visual Studio 2017 Update 2
  • Install TypeScript 2.3 for Visual Studio (This is not only for VS 2015 but also for VS 2017 Update 2)
  • Put tslint.json in C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.3 or any of its parent directories and run npm install typescript tslint tslint-language-service (Visual Studio doesn't search for tslint.json or plugins in the project folder)
  • Add "plugins": [{ "name": "tslint-language-service" }] to compilerOptions in your tsconfig.json

Now TSLint in Visual Studio should work:




回答2:


Web Analyser is there installed as part of Visual Studio 2017. The bad news: without tslint.

I suspect (was hoping) that it can be done using the taskrunner and gulp and piping the output back into the Visual Studio 2017 errors window (using the 'msbuild' output of tslint), but when I tried this I couldn't get it to work, and I don't have the time to work it out why. It may be this output option is not supported in vs2017.

My solution was to roll back to vs2015 community. (I also got back the code lens feature which I had grown to depend on.) I'm hoping that these things will come back to vs eventually, so I can move forward to some of the new features.

UPDATE: Rich Newman has written a replacement called TypeScript Analyzerfor vs2017 https://marketplace.visualstudio.com/items?itemName=RichNewman.TypeScriptAnalyzer




回答3:


Since this is the top google result, I wanted to add a more recent answer. Microsoft has a tslint plugin now that works with Typescript 3+ and across Visual Studio, VSCode and other editors:

https://github.com/Microsoft/typescript-tslint-plugin

Setup

Install Dependencies

npm install --save-dev typescript tslint typescript-tslint-plugin

Add to tsconfig.json:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-tslint-plugin"
      }
    ]
  }
}

Develop with lint!




回答4:


Thanks to Rich N, now there is TypeScript Analyzer for Visual Studio 2017. See his answer to an SO question on the same topic here.



来源:https://stackoverflow.com/questions/42824723/set-up-tslint-for-vs2017

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!