VScode 没有向我显示任何样式错误。
package.json:
...
"postcss": "^8.4.12",
"postcss-scss": "^4.0.3",
"stylelint": "^14.7.1",
"stylelint-config-sass-guidelines": "^9.0.1",
.stylelintrc.json:
{
"extends": "stylelint-config-sass-guidelines",
"files": ["**/*.scss"],
"customSyntax": "postcss-scss",
"rules": {
"color-named": "always-where-possible",
"max-nesting-depth": 5,
"selector-max-compound-selectors": 6,
"selector-no-qualifying-type": [
true,
{
"ignore": ["attribute", "class", "id"]
}
],
"selector-max-id": 1,
"no-extra-semicolons": true
}
}
vscode 设置.json
...
"stylelint.enable": true,
"css.validate": false,
"scss.validate": false,
"less.validate": false,
这就是我配置的所有内容。我在 vscodestylelint 1.2.2 上。 Stylelint 它自己在控制台中工作得很好,vscode 只是不会显示任何错误。
最佳答案
Like Stylelint itself , Stylelint VS Code extension only lints CSS by default .您必须使用 stylelint.validate
property 配置扩展以 lint 其他语言,例如 SCSS :
// vscode settings.json
...
"css.validate": false,
"scss.validate": false,
"stylelint.validate": ["css", "scss"],
这将关闭 VS Code 的内置 CSS 和 SCSS 验证器,然后为它们打开 Stylelint。
关于css - Stylelint 不会在 VSCode 中标记错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71955851/