stylelint 是css的代码检查工具, 方便规范css带啊吗规范


依赖包


npm i stylelint stylelint-webpack-plugin stylelint-config-standard --save-dev

配置文件

  • webpack.dev.conf.js
const StyleLintPlugin = require('stylelint-webpack-plugin')


plugins中添加

new StyleLintPlugin({
	// 正则匹配想要lint监测的文件
	files: ['src/**/*.vue', 'src/assets/css/*.l?(e|c)ss']
}),

  • 忽略检查文件 .stylelintignore
根据自己项目来把, 比如

src/assets/css/*.css
  • 检查规则 .stylelintrc.js
module.exports = {
    "extends": "stylelint-config-standard",
    "rules": {
        "rule-empty-line-before": "never",
        "selector-list-comma-newline-after": "never-multi-line",
        "string-quotes": "single",
        "indentation": 4,
        "selector-pseudo-element-colon-notation": "single",
        "no-descending-specificity": null
    }
}

Logo

前往低代码交流专区

更多推荐