所需安装包:stylelint stylelint-webpack-config
常用 extends:stylelint-config-standard stylelint-config-recommended
webpack.config.js
const StyleLintPlugin = require('stylelint-webpack-plugin');
const ENABLE_STYLELINT = true;
module.exports = {
// ...
plugins: [
...ENABLE_STYLELINT ? [new StyleLintPlugin({
files: ['**/*.css', '**/*.less', '**/*.html']
})] : []
]
}
package.json
{
"stylelint": {
"extends": "stylelint-config-standard",
"rules": {
"indentation": 4,
"no-missing-end-of-source-newline": null
}
}
}
indentation 缩进
默认为 2,建议设置为 4
no-missing-end-of-source-newline 最后一行必须留白
默认为 true,设置为 null 为关闭