Przeglądaj źródła

stylelint.config.js 规则修改

dusenyao 2 lat temu
rodzic
commit
493933eceb
3 zmienionych plików z 89 dodań i 48 usunięć
  1. 27 26
      package-lock.json
  2. 6 5
      package.json
  3. 56 17
      stylelint.config.js

+ 27 - 26
package-lock.json

@@ -11,8 +11,8 @@
         "@tinymce/tinymce-vue": "^3.2.8",
         "awe-dnd": "^0.3.4",
         "axios": "^1.3.4",
-        "book-ui": "file:../book-ui-0.3.27.tgz",
-        "core-js": "^3.29.0",
+        "book-ui": "file:../book-ui-0.3.28.tgz",
+        "core-js": "^3.29.1",
         "dayjs": "^1.11.7",
         "element-ui": "^2.15.13",
         "jquery": "^3.6.4",
@@ -53,11 +53,12 @@
         "postcss": "^8.4.21",
         "postcss-html": "^1.5.0",
         "prettier": "2.8.4",
-        "sass": "^1.58.3",
+        "sass": "^1.59.2",
         "sass-loader": "^10.4.1",
         "script-ext-html-webpack-plugin": "^2.1.5",
         "stylelint": "^15.2.0",
         "stylelint-config-recess-order": "^4.0.0",
+        "stylelint-config-recommended-scss": "^9.0.1",
         "stylelint-config-recommended-vue": "^1.4.0",
         "stylelint-config-standard-scss": "^7.0.1",
         "stylelint-declaration-block-no-ignored-properties": "^2.7.0",
@@ -5777,9 +5778,9 @@
       }
     },
     "node_modules/book-ui": {
-      "version": "0.3.27",
-      "resolved": "file:../book-ui-0.3.27.tgz",
-      "integrity": "sha512-YxPe79MGEUPxfnOU4J87eAbBQuic2RX2Nuxlj82Yk/fUjH4mFybf2o+vawSbYCIe5x57qFvU9gwP+iTOlFoEcQ==",
+      "version": "0.3.28",
+      "resolved": "file:../book-ui-0.3.28.tgz",
+      "integrity": "sha512-BmaDm1h35WkNsWpHaoq+E+LCi8GSwLMgUuL32Jx10Z4FVhTd0eBU103UssbvhemSycVz5E1YFtgkK0V5+E691Q==",
       "dependencies": {
         "awe-dnd": "^0.3.4",
         "axios": "^0.21.1",
@@ -6930,9 +6931,9 @@
       }
     },
     "node_modules/core-js": {
-      "version": "3.29.0",
-      "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.29.0.tgz",
-      "integrity": "sha512-VG23vuEisJNkGl6XQmFJd3rEG/so/CNatqeE+7uZAwTSwFeB/qaO0be8xZYUNWprJ/GIwL8aMt9cj1kvbpTZhg==",
+      "version": "3.29.1",
+      "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.29.1.tgz",
+      "integrity": "sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw==",
       "hasInstallScript": true
     },
     "node_modules/core-js-compat": {
@@ -18535,9 +18536,9 @@
       "license": "MIT"
     },
     "node_modules/sass": {
-      "version": "1.58.3",
-      "resolved": "https://registry.npmmirror.com/sass/-/sass-1.58.3.tgz",
-      "integrity": "sha512-Q7RaEtYf6BflYrQ+buPudKR26/lH+10EmO9bBqbmPh/KeLqv8bjpTNqxe71ocONqXq+jYiCbpPUmQMS+JJPk4A==",
+      "version": "1.59.2",
+      "resolved": "https://registry.npmmirror.com/sass/-/sass-1.59.2.tgz",
+      "integrity": "sha512-jJyO6SmbzkJexF8MUorHx5tAilcgabioYxT/BHbY4+OvoqmbHxsYlrjZ8Adhqcgl6Zqwie0TgMXLCAmPFxXOuw==",
       "dev": true,
       "dependencies": {
         "chokidar": ">=3.0.0 <4.0.0",
@@ -20098,9 +20099,9 @@
       }
     },
     "node_modules/stylelint-config-recommended-scss": {
-      "version": "9.0.0",
-      "resolved": "https://registry.npmmirror.com/stylelint-config-recommended-scss/-/stylelint-config-recommended-scss-9.0.0.tgz",
-      "integrity": "sha512-5e9pn3Ztfncd8s9OqvvCW7tZpYe+vGmPi7VEXX7XEp+Kj38PnKCrvFCBL+hQ7rkD4d5QzjB3BxlFEyo/30UWUw==",
+      "version": "9.0.1",
+      "resolved": "https://registry.npmmirror.com/stylelint-config-recommended-scss/-/stylelint-config-recommended-scss-9.0.1.tgz",
+      "integrity": "sha512-qAmz/TdrqslwiMTuLM3QXeISUkfEDUXGMfRBCHm/xrkCJNnQefv+mzG2mWTsWkqcVk8HAyUkug10dwAcYp2fCQ==",
       "dev": true,
       "dependencies": {
         "postcss-scss": "^4.0.2",
@@ -27687,8 +27688,8 @@
       }
     },
     "book-ui": {
-      "version": "file:..\\book-ui-0.3.27.tgz",
-      "integrity": "sha512-YxPe79MGEUPxfnOU4J87eAbBQuic2RX2Nuxlj82Yk/fUjH4mFybf2o+vawSbYCIe5x57qFvU9gwP+iTOlFoEcQ==",
+      "version": "file:..\\book-ui-0.3.28.tgz",
+      "integrity": "sha512-BmaDm1h35WkNsWpHaoq+E+LCi8GSwLMgUuL32Jx10Z4FVhTd0eBU103UssbvhemSycVz5E1YFtgkK0V5+E691Q==",
       "requires": {
         "awe-dnd": "^0.3.4",
         "axios": "^0.21.1",
@@ -28508,9 +28509,9 @@
       }
     },
     "core-js": {
-      "version": "3.29.0",
-      "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.29.0.tgz",
-      "integrity": "sha512-VG23vuEisJNkGl6XQmFJd3rEG/so/CNatqeE+7uZAwTSwFeB/qaO0be8xZYUNWprJ/GIwL8aMt9cj1kvbpTZhg=="
+      "version": "3.29.1",
+      "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.29.1.tgz",
+      "integrity": "sha512-+jwgnhg6cQxKYIIjGtAHq2nwUOolo9eoFZ4sHfUH09BLXBgxnH4gA0zEd+t+BO2cNB8idaBtZFcFTRjQJRJmAw=="
     },
     "core-js-compat": {
       "version": "3.24.0",
@@ -36552,9 +36553,9 @@
       "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
     },
     "sass": {
-      "version": "1.58.3",
-      "resolved": "https://registry.npmmirror.com/sass/-/sass-1.58.3.tgz",
-      "integrity": "sha512-Q7RaEtYf6BflYrQ+buPudKR26/lH+10EmO9bBqbmPh/KeLqv8bjpTNqxe71ocONqXq+jYiCbpPUmQMS+JJPk4A==",
+      "version": "1.59.2",
+      "resolved": "https://registry.npmmirror.com/sass/-/sass-1.59.2.tgz",
+      "integrity": "sha512-jJyO6SmbzkJexF8MUorHx5tAilcgabioYxT/BHbY4+OvoqmbHxsYlrjZ8Adhqcgl6Zqwie0TgMXLCAmPFxXOuw==",
       "dev": true,
       "requires": {
         "chokidar": ">=3.0.0 <4.0.0",
@@ -37924,9 +37925,9 @@
       "dev": true
     },
     "stylelint-config-recommended-scss": {
-      "version": "9.0.0",
-      "resolved": "https://registry.npmmirror.com/stylelint-config-recommended-scss/-/stylelint-config-recommended-scss-9.0.0.tgz",
-      "integrity": "sha512-5e9pn3Ztfncd8s9OqvvCW7tZpYe+vGmPi7VEXX7XEp+Kj38PnKCrvFCBL+hQ7rkD4d5QzjB3BxlFEyo/30UWUw==",
+      "version": "9.0.1",
+      "resolved": "https://registry.npmmirror.com/stylelint-config-recommended-scss/-/stylelint-config-recommended-scss-9.0.1.tgz",
+      "integrity": "sha512-qAmz/TdrqslwiMTuLM3QXeISUkfEDUXGMfRBCHm/xrkCJNnQefv+mzG2mWTsWkqcVk8HAyUkug10dwAcYp2fCQ==",
       "dev": true,
       "requires": {
         "postcss-scss": "^4.0.2",

+ 6 - 5
package.json

@@ -10,14 +10,14 @@
     "svgo": "svgo -f src/icons/svg",
     "test:unit": "jest --clearCache && vue-cli-service test:unit",
     "lint": "eslint --ext .js,.vue src",
-    "lint:css": "stylelint **/*.{html,vue,css,sass,scss,less}"
+    "lint:css": "stylelint --cache --fix \"src/**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/"
   },
   "dependencies": {
     "@tinymce/tinymce-vue": "^3.2.8",
     "awe-dnd": "^0.3.4",
     "axios": "^1.3.4",
     "book-ui": "file:../book-ui-0.3.28.tgz",
-    "core-js": "^3.29.0",
+    "core-js": "^3.29.1",
     "dayjs": "^1.11.7",
     "element-ui": "^2.15.13",
     "jquery": "^3.6.4",
@@ -58,20 +58,21 @@
     "postcss": "^8.4.21",
     "postcss-html": "^1.5.0",
     "prettier": "2.8.4",
-    "sass": "^1.58.3",
+    "sass": "^1.59.2",
     "sass-loader": "^10.4.1",
     "script-ext-html-webpack-plugin": "^2.1.5",
     "stylelint": "^15.2.0",
     "stylelint-config-recess-order": "^4.0.0",
+    "stylelint-config-recommended-scss": "^9.0.1",
     "stylelint-config-recommended-vue": "^1.4.0",
     "stylelint-config-standard-scss": "^7.0.1",
     "stylelint-declaration-block-no-ignored-properties": "^2.7.0",
     "stylelint-webpack-plugin": "^4.1.0",
     "svg-sprite-loader": "^6.0.11",
     "svgo": "^2.8.0",
+    "vue-demi": "^0.13.11",
     "vue-loader": "^15.10.1",
-    "vue-template-compiler": "^2.7.14",
-    "vue-demi": "^0.13.11"
+    "vue-template-compiler": "^2.7.14"
   },
   "browserslist": [
     "> 1%",

+ 56 - 17
stylelint.config.js

@@ -1,15 +1,46 @@
 module.exports = {
+  root: true,
   defaultSeverity: 'warning',
-  extends: ['stylelint-config-standard-scss', 'stylelint-config-recess-order', 'stylelint-config-recommended-vue'],
+  extends: ['stylelint-config-recommended-scss', 'stylelint-config-recess-order', 'stylelint-config-standard-scss'],
   plugins: ['stylelint-declaration-block-no-ignored-properties'],
   rules: {
-    'scss/no-global-function-names': null,
-    'plugin/declaration-block-no-ignored-properties': true,
+    'scss/dollar-variable-pattern': null,
+    'selector-class-pattern': null,
     'order/properties-alphabetical-order': null,
+    // 嵌套过多,建议关闭此规则
     'no-descending-specificity': null,
-    // 样式块中不允许重复的属性
-    'declaration-block-no-duplicate-properties': true,
-    // 指定颜色函数使用传统符号隔开
+    'selector-max-id': 1,
+    'selector-pseudo-class-no-unknown': [
+      true,
+      {
+        ignorePseudoClasses: ['deep', 'global']
+      }
+    ],
+    'at-rule-no-unknown': [
+      true,
+      {
+        ignoreAtRules: [
+          'tailwind',
+          'apply',
+          'variants',
+          'responsive',
+          'screen',
+          'function',
+          'if',
+          'each',
+          'extend',
+          'include',
+          'mixin',
+          'at-root'
+        ]
+      }
+    ],
+    'rule-empty-line-before': [
+      'always',
+      {
+        ignore: ['after-comment', 'first-nested']
+      }
+    ],
     'color-function-notation': 'legacy',
     // 函数 url 链接不允许 shceme relative
     'function-url-no-scheme-relative': true,
@@ -17,8 +48,6 @@ module.exports = {
     'declaration-block-no-redundant-longhand-properties': true,
     // 选择器最大深度
     'selector-max-compound-selectors': 12,
-    // 限制 id选择器的数目在一个选择器中
-    'selector-max-id': 1,
     // 最多2个类型选择器
     'selector-max-type': 2,
     // 不允许未知的动画
@@ -27,14 +56,24 @@ module.exports = {
     'font-family-name-quotes': 'always-unless-keyword',
     // url 函数内部必须有引号
     'function-url-quotes': 'always',
-    // 为类选择器指定一个模式
-    'selector-class-pattern': null,
-    'at-rule-no-unknown': [true, { ignoreAtRules: ['import', 'include', 'mixin', 'include', 'extend', 'each'] }],
+    'value-keyword-case': ['lower', { ignoreKeywords: ['optimizeLegibility', 'currentColor'] }],
     'max-nesting-depth': [12, { ignore: ['blockless-at-rules', 'pseudo-classes'] }],
-    'selector-no-qualifying-type': [true, { ignore: ['attribute', 'class', 'id'] }],
-    'value-keyword-case': ['lower', { camelCaseSvgKeywords: true }],
-    'value-no-vendor-prefix': [true, { ignoreValues: ['box'] }],
-    'selector-pseudo-class-no-unknown': [true, { ignorePseudoClasses: ['deep'] }]
-    // 'declaration-property-value-no-unknown': [true, { ignoreProperties: { '/.+/': '/^v-bind(.*)$/' } }]
-  }
+    'selector-no-qualifying-type': [true, { ignore: ['attribute', 'class', 'id'] }]
+  },
+  ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
+  overrides: [
+    {
+      files: ['*.vue', '**/*.vue'],
+      extends: [
+        'stylelint-config-recess-order',
+        'stylelint-config-standard-scss',
+        'stylelint-config-recommended-vue/scss'
+      ],
+      rules: {
+        'keyframes-name-pattern': null,
+        'declaration-property-value-no-unknown': [true, { ignoreProperties: { '/.+/': '/(v-bind(.*))|($.*)/' } }],
+        'selector-pseudo-element-no-unknown': true
+      }
+    }
+  ]
 };