vue項目中配置stylelint


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
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章