stylelint.config.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. module.exports = {
  2. root: true,
  3. defaultSeverity: 'error',
  4. plugins: ['stylelint-order'],
  5. customSyntax: 'postcss-scss',
  6. extends: [
  7. 'stylelint-config-standard', // the standard shareable config for Stylelint
  8. 'stylelint-config-html/html', // the shareable html config for Stylelint.
  9. 'stylelint-config-html/vue', // the shareable vue config for Stylelint.
  10. 'stylelint-config-recess-order', // use the clean order for properties
  11. ],
  12. rules: {
  13. // 禁止在覆盖高特异性选择器之后出现低特异性选择器
  14. 'no-descending-specificity': null,
  15. // 禁止空源码
  16. 'no-empty-source': null,
  17. // 禁止字体族中缺少泛型族关键字
  18. 'font-family-no-missing-generic-family-keyword': null,
  19. // 禁止未知的@规则
  20. 'at-rule-no-unknown': [
  21. true,
  22. {
  23. ignoreAtRules: [
  24. 'tailwind',
  25. 'apply',
  26. 'variants',
  27. 'responsive',
  28. 'screen',
  29. 'function',
  30. 'if',
  31. 'each',
  32. 'include',
  33. 'mixin',
  34. ],
  35. },
  36. ],
  37. // 不允许未知函数
  38. 'function-no-unknown': null,
  39. // 不允许未知单位a
  40. 'unit-no-unknown': [true, { ignoreUnits: ['rpx'] }],
  41. // 标记 CSS 规范中未知属性值
  42. // 'declaration-property-value-no-unknown': true,
  43. // 'scss/at-rule-no-unknown': true,
  44. // 'scss/dollar-variable-pattern': '^[a-z]+([a-z0-9-]+[a-z0-9]+)?$',
  45. // 不允许选择器使用供应商前缀
  46. 'selector-no-vendor-prefix': null,
  47. // 指定关键帧名称的模式
  48. 'keyframes-name-pattern': null,
  49. // 指定类选择器的模式
  50. 'selector-class-pattern': null,
  51. // 允许位置css selector
  52. 'selector-type-no-unknown': [true, { ignore: ['custom-elements', 'default-namespace'] }],
  53. // 不允许值使用供应商前缀
  54. 'value-no-vendor-prefix': null,
  55. // 要求或禁止在规则之前的空行
  56. 'rule-empty-line-before': ['always', { ignore: ['after-comment', 'first-nested'] }],
  57. },
  58. ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts'],
  59. overrides: [
  60. {
  61. files: ['*.scss', '*.vue', '**/*.vue', '*.html', '**/*.html'],
  62. customSyntax: 'postcss-html',
  63. rules: {
  64. // 禁止未知的伪类选择器
  65. 'selector-pseudo-class-no-unknown': [true, { ignorePseudoClasses: ['deep', 'global'] }],
  66. // 禁止未知的伪元素选择器
  67. 'selector-pseudo-element-no-unknown': [true, { ignorePseudoElements: ['v-deep', 'v-global', 'v-slotted'] }],
  68. },
  69. },
  70. ],
  71. };