前言
新项目制定规范接入了stylelint
,并通过husky
在git提交时去触发检测修复,stylelint
版本信息如下:
"stylelint": "^16.8.1",
"stylelint-config-standard": "^36.0.1",
"stylelint-less": "^3.0.1",
"stylelint-order": "^6.0.4",
内容
因为使用的是NutUi,所以无法直接调整组件对应的类名称,只好在stylelint.config.js
中加入相应的rules
进行配置;
module.exports = {
defaultSeverity: 'error',
extends: ['stylelint-config-standard'],
plugins: ['stylelint-less'],
overrides: [
{
files: ['**/*.html', '**/*.vue'],
customSyntax: 'postcss-html',
},
{
files: ['**/*.less'],
customSyntax: 'postcss-less',
},
],
rules: {
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: ['deep'],
},
],
'selector-class-pattern': [
'^((?!\\.nut).)*$',
{
message: "Expected class selector not to start with '.nut'",
},
],
},
};