stylelint.config.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* eslint-disable filenames/match-regex */
  2. module.exports = {
  3. extends: [
  4. // Use the Standard config as the base
  5. // https://github.com/stylelint/stylelint-config-standard
  6. 'stylelint-config-standard',
  7. // Enforce a standard order for CSS properties
  8. // https://github.com/stormwarning/stylelint-config-recess-order
  9. 'stylelint-config-recess-order',
  10. // Override rules that would interfere with Prettier
  11. // https://github.com/shannonmoeller/stylelint-config-prettier
  12. 'stylelint-config-prettier',
  13. // Override rules to allow linting of CSS modules
  14. // https://github.com/pascalduez/stylelint-config-css-modules
  15. 'stylelint-config-css-modules',
  16. ],
  17. plugins: [
  18. // Bring in some extra rules for SCSS
  19. 'stylelint-scss',
  20. 'stylelint-no-unsupported-browser-features',
  21. 'stylelint-declaration-use-variable',
  22. ],
  23. // Rule lists:
  24. // - https://stylelint.io/user-guide/rules/
  25. // - https://github.com/kristerkari/stylelint-scss#list-of-rules
  26. rules: {
  27. 'no-empty-source': null,
  28. // Allow newlines inside class attribute values
  29. 'string-no-newline': null,
  30. // Enforce camelCase for classes and ids, to work better
  31. // with CSS modules
  32. 'selector-class-pattern': [
  33. /^(vuecal__)?[a-z-]+$/,
  34. {
  35. message: 'class名只能使用小写字母和“-”\n',
  36. },
  37. ],
  38. 'selector-id-pattern': [
  39. /^[a-z-]+$/,
  40. {
  41. message: 'id名只能使用小写字母和“-”\n',
  42. },
  43. ],
  44. // Limit the number of universal selectors in a selector,
  45. // to avoid very slow selectors
  46. 'selector-max-universal': 1,
  47. // Disallow allow global element/type selectors in scoped modules
  48. 'selector-max-type': [0, { ignore: ['child', 'descendant', 'compounded'] }],
  49. // ===
  50. // SCSS
  51. // ===
  52. 'scss/dollar-variable-colon-space-after': 'always',
  53. 'scss/dollar-variable-colon-space-before': 'never',
  54. 'scss/dollar-variable-no-missing-interpolation': true,
  55. 'scss/dollar-variable-pattern': /^[a-z-]+$/,
  56. 'scss/double-slash-comment-whitespace-inside': 'always',
  57. 'scss/operator-no-newline-before': true,
  58. 'scss/operator-no-unspaced': true,
  59. 'scss/selector-no-redundant-nesting-selector': true,
  60. // Allow SCSS and CSS module keywords beginning with `@`
  61. 'at-rule-no-unknown': null,
  62. 'scss/at-rule-no-unknown': true,
  63. // scss 嵌套的优先级计算有问题
  64. 'no-descending-specificity': null,
  65. // 检测浏览器不支持的特性
  66. 'plugin/no-unsupported-browser-features': [
  67. true,
  68. {
  69. severity: 'warning',
  70. ignore: [
  71. 'user-select-none',
  72. 'css3-cursors',
  73. 'flexbox',
  74. 'calc',
  75. 'css-resize',
  76. 'viewport-units',
  77. ],
  78. },
  79. ],
  80. // 禁止使用important
  81. 'declaration-no-important': [
  82. true,
  83. {
  84. message: '禁止使用important,导致项目覆盖样式困难\n',
  85. },
  86. ],
  87. // 禁止使用厂商前缀(postCSS会自动处理),如-webkit-
  88. 'at-rule-no-vendor-prefix': [
  89. true,
  90. {
  91. message: '禁止使用厂商前缀,postCSS会自动处理\n',
  92. },
  93. ],
  94. 'media-feature-name-no-vendor-prefix': [
  95. true,
  96. {
  97. message: '禁止使用厂商前缀,postCSS会自动处理\n',
  98. },
  99. ],
  100. 'value-no-vendor-prefix': [
  101. true,
  102. {
  103. message: '禁止使用厂商前缀,postCSS会自动处理\n',
  104. },
  105. ],
  106. 'property-no-vendor-prefix': [
  107. true,
  108. {
  109. message: '禁止使用厂商前缀,postCSS会自动处理\n',
  110. },
  111. ],
  112. 'selector-no-vendor-prefix': [
  113. true,
  114. {
  115. message: '禁止使用厂商前缀,postCSS会自动处理\n',
  116. },
  117. ],
  118. // 禁止直接使用绝对大小的字号
  119. 'declaration-property-unit-disallowed-list': [
  120. {
  121. 'font-size': ['pt', 'px'],
  122. 'line-height': ['pt', 'px'],
  123. },
  124. {
  125. message: `主题中会更改字号,所以font-size需要引用相关变量,如$font-size-base、$font-size-lg\nline-height请使用相对值,如1.5\n`,
  126. },
  127. ],
  128. // 禁止直接使用色值。应该使用主题中的变量
  129. 'sh-waqar/declaration-use-variable': [
  130. [
  131. '/color/',
  132. 'font-family',
  133. {
  134. ignoreValues: ['currentColor', 'inherit', 'transparent', 'initial'],
  135. },
  136. ],
  137. {
  138. message: `主题中会更改颜色和字体,所以需要引用相关变量,如$primary-color、$component-background\n`,
  139. },
  140. ],
  141. },
  142. ignoreFiles: ['**/*.js', 'public/*.*', 'src/common/design/index.scss', 'src_custom/www/**/*.*'],
  143. }