css - Stylelint 不会在 VSCode 中标记错误

标签 css node.js visual-studio-code sass stylelint

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/

相关文章:

html - Bootstrap hidden-sm-down 不工作

html - css - 显示 : table-cell and fixed width

css - 移动按钮推送内容

javascript - 如何根据属性的总和来组织对象数组?

javascript - 无法访问数组中的对象,只能访问对象本身

reactjs - VSCode 不会在 React 中自动完成 HTML 标签

visual-studio-code - VS 代码有 "quick documentation"快捷方式吗?

javascript - 如何在 JQuery 中将其他元素添加到 Accordion 的标题中?

javascript - node.js 中的内存使用量不会减少吗?这是怎么回事?

Angular 2 bundle ,如导入/导入多个模块