module.exports = { extends: [ 'stylelint-config-standard', 'stylelint-config-recommended-less', 'stylelint-config-recommended-scss', 'stylelint-config-recommended-vue', // 解决 eslint 与 stylelint 冲突 'stylelint-config-prettier', 'stylelint-config-prettier-scss' ], plugins: ['stylelint-less', 'stylelint-scss', 'stylelint-order'], // 不同格式的文件指定自定义语法 overrides: [ { files: ['**/*.(html|vue)'], customSyntax: 'postcss-html' }, { files: ['**/*.(css|html)'], customSyntax: 'postcss-css' }, { files: ['**/*.(less|vue)'], customSyntax: 'postcss-less' }, { files: ['**/*.(scss|vue)'], customSyntax: 'postcss-scss' } ], ignoreFiles: [ '**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx', '**/*.d.ts', '**/*.json', '**/*.md', '**/*.lock', '**/*.yaml' ], rules: { 'at-rule-no-unknown': null, // 避免使用 @include 报错 'alpha-value-notation': 'number', // 指定 alpha 值的百分比或数字表示法。 'block-no-empty': null, // 禁止空块。 'block-closing-brace-newline-before': 'always', // 在块的右大括号之前需要换行符或不允许空格(可自动修复)。 'block-closing-brace-newline-after': 'always', // 在块的右大括号之后需要换行符或不允许空格(可自动修复)。 'block-opening-brace-space-before': 'always', // 在块的左大括号之前需要一个空格或不允许空格(可自动修复)。 'block-opening-brace-newline-after': 'always', // 在块的左大括号后需要换行符(可自动修复)。 'color-hex-case': 'lower', // 为十六进制颜色指定小写或大写(可自动修复)。 'color-hex-length': 'long', // 为十六进制颜色指定短符号或长符号(可自动修复)。 'declaration-colon-space-after': 'always', // 属性声明冒号后需要有个空格 'declaration-block-semicolon-newline-after': 'always', // 声明块的分号后需要换行符或不允许空格(可自动修复)。 // 'declaration-block-single-line-max-declarations': null, // 限制单行声明块中的声明数量。 'font-family-no-missing-generic-family-keyword': null, // 不允许在字体系列名称列表中缺少通用系列。 indentation: 2, // 指定缩进(可自动修复)。 'keyframes-name-pattern': null, // 动画 @keyframes 名称随意 'length-zero-no-unit': true, // 不允许使用零长度的单位。 'no-empty-source': null, // 禁止空源。 'no-descending-specificity': null, // 禁止在具有较高优先级的选择器后出现被其覆盖的较低优先级的选择器 'property-no-unknown': null, // 禁止未知属性。 'rule-empty-line-before': 'never', // 在规则之前要求或禁止空行(可自动修复)。 'selector-class-pattern': null, // css 变量名随意 // 'selector-list-comma-space-after': 'always', // 选择器列表的逗号后需要一个空格或不允许空格(可自动修复)。 'selector-pseudo-element-no-unknown': [ true, { ignorePseudoElements: ['v-deep', 'input-placeholder'] } ], // 添加未知的选择器元素 'selector-pseudo-class-no-unknown': [ true, { ignorePseudoClasses: ['deep', 'input-placeholder'] } ], // 添加未知的选择器类名 'unit-no-unknown': [true, { ignoreUnits: ['/rpx/', '/upx/'] }], // 禁止未知单位。 'unit-case': 'lower', // 为单位指定小写或大写(可自动修复)。 'value-keyword-case': null, // 为关键字的值指定大写还是小写 null 不指定(会把驼峰变量全部格式为大写或小写) // 指定样式的排序 'order/properties-order': [ '@include', 'position', 'top', 'right', 'bottom', 'left', 'z-index', 'flex', 'display', 'flex-direction', 'justify-content', 'align-items', 'grid', 'grid-template-rows', 'grid-template-columns', 'grid-auto-rows', 'grid-auto-columns', 'gap', 'grid-gap', 'align-items', 'justify-self', 'align-self', 'float', 'clear', 'overflow', 'overflow-x', 'overflow-y', 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left', 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', 'width', 'min-width', 'max-width', 'height', 'min-height', 'max-height', 'font-size', 'font-family', 'text-align', 'text-justify', 'text-indent', 'text-overflow', 'text-decoration', 'white-space', 'color', 'background', 'background-position', 'background-repeat', 'background-size', 'background-color', 'background-clip', 'border', 'border-style', 'border-width', 'border-color', 'border-top-style', 'border-top-width', 'border-top-color', 'border-right-style', 'border-right-width', 'border-right-color', 'border-bottom-style', 'border-bottom-width', 'border-bottom-color', 'border-left-style', 'border-left-width', 'border-left-color', 'border-radius', 'opacity', 'filter', 'list-style', 'outline', 'visibility', 'box-shadow', 'text-shadow', 'resize', 'transition' ] } }