typescript 使用 SonarQube 分析打字稿

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42974395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:22:27  来源:igfitidea点击:

Analyse Typescript with SonarQube

typescriptsonarqubesonarlinttslint

提问by mahdi kallel

I'm using node_modules/codelyzerto analyze my source code Typescript. I define manually rules in tslint.jsonfile.

node_modules/codelyzer用来分析我的源代码Typescript。我在tslint.json文件中手动定义规则。

But it is possible to analyze Typescriptwith SonarQube?

但是可以TypescriptSonarQube?

采纳答案by Fabrice - SonarSource Team

You can use a plugin developed by the SonarQube community to support TypeScript.

您可以使用 SonarQube 社区开发的插件来支持 TypeScript。

You will find it on the "Other Plugins" page on the official SonarQube Plugin Library.

您可以在官方SonarQube 插件库的“其他插件”页面上找到它。

回答by isaac weathers

Just to chime in as I did not see the TypeScript plugin on that page. This one seems to be useful: https://github.com/Pablissimo/SonarTsPlugin

只是插一句,因为我在该页面上没有看到 TypeScript 插件。这个似乎很有用:https: //github.com/Pablissimo/SonarTsPlugin

回答by Denpal Rius

Just in case you are building using Visual Studio 2017, you can use the SonarScanner for MSBuild 4.2to build the .NET Core project(s) that contain your Typescript source code.

万一您使用 Visual Studio 2017 进行构建,您可以使用MSBuild 4.2SonarScanner来构建包含您的 Typescript 源代码的 .NET Core 项目。

For example in this case, the following commands are in a package.jsonfile for an Angular project:

例如,在本例中,以下命令位于Angular 项目的package.json文件中:

package.json file for an Angular project

Angular 项目的 package.json 文件

Set the following commands to be executed during buildin the .csprojfile:

.csproj文件中设置要在构建期间执行的以下命令:

enter image description here

在此处输入图片说明

You can then use the .NET Core dotnet build/publishtasks to build the project.

然后,您可以使用 .NET Coredotnet build/publish任务来构建项目。

After that, end the SonarScanner and analyse the results on SonarQube. You may see Typescript, Javascript and a bunch of other languages that you may have in your project. Using the VSTS CI tasks makes this uber easy.

之后,结束 SonarScanner 并在 SonarQube 上分析结果。您可能会在项目中看到 Typescript、Javascript 和许多其他语言。使用 VSTS CI 任务使这变得非常容易。