我正在使用webpack开发Angular2应用程序。我正在使用声纳库贝作为代码质量指标。我使用VS Code作为IDE。
下面的css在sonarqube上给了我一个警告"检查这个潜在的盒子模型尺寸问题",这是正确的。
.popup-dock-button {
background: url('./app/assets/images/dock.svg') no-repeat;
background-size: 13px 13px;
float: left;
width: 20px;
height: 20px;
padding: 3px;
}
但是在 VSCode 中,我无法看到此代码闻起来是警告。下面是我的 stylelintrc.json 文件
{
"extends": [
"stylelint-config-standard"
],
"plugins": [
"stylelint-scss"
],
"rules": {
"indentation": 4,
"number-leading-zero": null,
"declaration-block-no-ignored-properties": true,
"selector-class-pattern": "^[a-z][-a-z0-9]*$",
"selector-no-id": true
},
"defaultSeverity": "warning"
}
我找不到要设置以解决此问题的规则ID。
纳和stylelint是两种不同的工具。它们都能够进行CSS静态分析。但是,它们具有不同的规则、选项和配置。Sonar似乎是基于Java的,stylelint是用JavaScript for Node.js编写的。
它看起来像您正在运行的声纳作为 IDE 中 CI 和样式 lint 的一部分。这就是 CI 中的警告与 IDE 中的警告不同的原因。
仅供参考,Sonor CSS规则列表在这里。也许您会在那里找到一个选项来禁用"检查此潜在的框模型大小问题"规则。
看起来在样式lint中没有这样的规则。供您参考,我在 https://github.com/racodond/sonar-css-plugin/blob/master/doc/stylelint-sonarqube-rule-mapping.md 发起了一个 SonarQube/stylelint 规则映射