SonarQube:在 SonarQube 中为 JavaScript 集成 ESLint?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32519522/
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
SonarQube: Integrate ESLint for JavaScript in SonarQube?
提问by Stelos10
We have determined our rules, which should be used for JavaScript code, with ESLint. Now we want to integrate ESLint to SonarQubeas we did it before the same way with Checkstyle for JavaCode.
我们已经用 ESLint 确定了我们的规则,这些规则应该用于 JavaScript 代码。现在我们想将 ESLint 集成到 SonarQube 中,就像我们之前对 JavaCode 的 Checkstyle 所做的一样。
Under the following link it is described why SonarQube doesn't want to provide a plugin for ESLint: http://www.sonarqube.org/sonarqube-javascript-plugin-why-compete-with-jslint-and-jshint/
在以下链接中描述了为什么 SonarQube 不想为 ESLint 提供插件:http: //www.sonarqube.org/sonarqube-javascript-plugin-why-compete-with-jslint-and-jshint/
Is there still no plugin fir ESLint in SonarQube?Isn't this part of a marketing strategy? There is also a plugin for Checkstyle, FindBugs etc... Why does SonarQube suddenly stop to support the integration of other code analysing tools?
SonarQube 中还没有 ESLint 插件吗?这不是营销策略的一部分吗?还有Checkstyle、FindBugs等插件……为什么SonarQube突然停止支持其他代码分析工具的集成了?
回答by G. Ann - SonarSource Team
Yes, there is still no plugin for ESLint, and this is part of the strategy, but in the other direction.
是的,ESLint 仍然没有插件,这是策略的一部分,但在另一个方向。
In fact, our first plugins were for external analyzers, and over time we realized that simply aggregating other tools' results didn't truly serve the community because that community was coming to us with rule bugs, requests and suggestions for improvement - and all we could do was refer them on the tools' makers.
事实上,我们的第一个插件是用于外部分析器的,随着时间的推移,我们意识到简单地聚合其他工具的结果并不能真正为社区服务,因为社区会向我们提出规则错误、请求和改进建议——以及我们所有的可以做的就是将他们介绍给工具制造商。
So we started writing our own rules instead for better responsiveness and, we believe, enhanced accuracy.
因此,我们开始编写自己的规则,以提高响应速度,我们相信,这也提高了准确性。
I urge you to take the rules you feel are missing to the SonarQube Google Group
我敦促您遵守 SonarQube Google Group 所缺少的规则
EditThe strategy has come full circle. SonarJS now imports ESLint reports.
编辑该策略已经完成了一个完整的循环。SonarJS 现在导入 ESLint 报告。
回答by Carlos Melo
I have not tried it yet, but I've just discovered this plugin that seems to be very promising for any front end project:
我还没有尝试过,但我刚刚发现这个插件似乎对任何前端项目都非常有前途:
https://github.com/groupe-sii/sonar-web-frontend-plugin
https://github.com/groupe-sii/sonar-web-frontend-plugin
It may worth giving a try
值得一试
回答by Rocío García Luque
You have a good option here: https://github.com/sleroy/SonarEsLintPlugin
您在这里有一个不错的选择:https: //github.com/sleroy/SonarEsLintPlugin
From the docs:
从文档:
? Install Node.js
? 安装 Node.js
? Install EsLint (3+) with npm install -g eslint, or ensure it is installed locally against your project
? 使用 npm install -g eslint 安装 EsLint (3+),或者确保它是针对您的项目在本地安装的
? If you're installing globally, find the path to EsLint and copy it - will be similar to C:\Users\ [Username]\AppData\Roaming\npm\node_modules\eslint\bin\eslint.js on Windows
? 如果你是全局安装,找到 EsLint 的路径并复制它 - 在 Windows 上将类似于 C:\Users\ [用户名]\AppData\Roaming\npm\node_modules\eslint\bin\eslint.js
? Copy .jar file (downloaded from https://github.com/sleroy/SonarEsLintPlugin/releasespage) to SonarQube extensions folder
? 将 .jar 文件(从https://github.com/sleroy/SonarEsLintPlugin/releases页面下载)复制到 SonarQube 扩展文件夹
? Restart SonarQube server
? 重启 SonarQube 服务器
? Browse to SonarQube web interface, login as Admin, hit up Settings
? 浏览到 SonarQube 网络界面,以管理员身份登录,点击设置
? Hit the Rules tab, then the EsLint rule set, then apply it to your project - alter rule activation as required
? 点击“规则”选项卡,然后点击 EsLint 规则集,然后将其应用于您的项目 - 根据需要更改规则激活
回答by Ilarion Halushka
SonarSource eslint-plugin-sonarjs https://github.com/SonarSource/eslint-plugin-sonarjs
SonarSource eslint-plugin-sonarjs https://github.com/SonarSource/eslint-plugin-sonarjs