Jelajahi Sumber

tool(组件): 增加prettier,jest,eslint等一些基本配置

gemercheung 2 tahun lalu
induk
melakukan
127b36cbb0
8 mengubah file dengan 3845 tambahan dan 17433 penghapusan
  1. 23 28
      .cz-config.js
  2. 50 50
      .eslintrc.js
  3. 4 4
      packages/commitlint-config.js
  4. 7 6
      package.json
  5. 1 1
      packages/foo/package.json
  6. 3750 17343
      pnpm-lock.yaml
  7. 0 1
      pnpm-workspace.yaml
  8. 10 0
      prettier.config.js

+ 23 - 28
.cz-config.js

@@ -1,42 +1,37 @@
 module.exports = {
   types: [
-    { value: "feat", name: "feat 🍄:    新增新的特性" },
-    { value: "fix", name: "fix 🐛:    修复 BUG" },
-    { value: "docs", name: "docs 📄:    修改文档、注释" }, 
+    { value: 'feat', name: 'feat 🍄:    新增新的特性' },
+    { value: 'fix', name: 'fix 🐛:    修复 BUG' },
+    { value: 'docs', name: 'docs 📄:    修改文档、注释' },
     {
-      value: "refactor",
-      name: "refactor 🎸:    代码重构,注意和特性、修复区分开",
+      value: 'refactor',
+      name: 'refactor 🎸:    代码重构,注意和特性、修复区分开',
     },
-    { value: "chore", name: "chore 🧹:   构建过程或辅助工具的变动" },
-    { value: "perf", name: "perf ⚡:    提升性能" },
-    { value: "test", name: "test 👀:    添加一个测试" },
-    { value: "tool", name: "tool 🚗:    开发工具变动(构建、脚手架工具等)" },
-    { value: "style", name: "style ✂:    对代码格式的修改不影响逻辑" },
-    { value: "revert", name: "revert 🌝:     版本回滚" },
-    { value: "update", name: "update ⬆:    第三方库升级 " },
+    { value: 'chore', name: 'chore 🧹:   构建过程或辅助工具的变动' },
+    { value: 'perf', name: 'perf ⚡:    提升性能' },
+    { value: 'test', name: 'test 👀:    添加一个测试' },
+    { value: 'tool', name: 'tool 🚗:    开发工具变动(构建、脚手架工具等)' },
+    { value: 'style', name: 'style ✂:    对代码格式的修改不影响逻辑' },
+    { value: 'revert', name: 'revert 🌝:     版本回滚' },
+    { value: 'update', name: 'update ⬆:    第三方库升级 ' },
   ],
 
-  scopes: [
-    { name: "组件" },
-    { name: "样式" },
-    { name: "文档更改" },
-    { name: "其它变更" },
-  ],
+  scopes: [{ name: '组件' }, { name: '样式' }, { name: '文档更改' }, { name: '其它变更' }],
   allowTicketNumber: false,
   isTicketNumberRequired: false,
-  ticketNumberPrefix: "TICKET-",
-  ticketNumberRegExp: "d{1,5}",
+  ticketNumberPrefix: 'TICKET-',
+  ticketNumberRegExp: 'd{1,5}',
   messages: {
-    type: "选择一种你的提交类型:",
-    scope: "选择一个scope (可选):",
-    customScope: "Denote the SCOPE of this change:",
-    subject: "简要说明:\n",
+    type: '选择一种你的提交类型:',
+    scope: '选择一个scope (可选):',
+    customScope: 'Denote the SCOPE of this change:',
+    subject: '简要说明:\n',
     body: '详细说明,使用"|"换行(可选):\n',
-    breaking: "非兼容性说明 (可选):\n",
-    footer: "关联关闭的issue,例如:#31, #34(可选):\n",
-    confirmCommit: "确定提交?",
+    breaking: '非兼容性说明 (可选):\n',
+    footer: '关联关闭的issue,例如:#31, #34(可选):\n',
+    confirmCommit: '确定提交?',
   },
   allowCustomScopes: true,
-  allowBreakingChanges: ["新增", "修复"],
+  allowBreakingChanges: ['新增', '修复'],
   subjectLimit: 100,
 };

+ 50 - 50
.eslintrc.js

@@ -1,5 +1,5 @@
 // @ts-check
-const { defineConfig } = require("eslint-define-config");
+const { defineConfig } = require('eslint-define-config');
 module.exports = defineConfig({
   root: true,
   env: {
@@ -7,75 +7,75 @@ module.exports = defineConfig({
     node: true,
     es6: true,
   },
-  parser: "vue-eslint-parser",
+  parser: 'vue-eslint-parser',
   parserOptions: {
-    parser: "@typescript-eslint/parser",
+    parser: '@typescript-eslint/parser',
     ecmaVersion: 2020,
-    sourceType: "module",
-    jsxPragma: "React",
+    sourceType: 'module',
+    jsxPragma: 'React',
     ecmaFeatures: {
       jsx: true,
     },
   },
   extends: [
-    "plugin:vue/vue3-recommended",
-    "plugin:@typescript-eslint/recommended",
-    "prettier",
-    "plugin:prettier/recommended",
-    "plugin:jest/recommended",
+    'plugin:vue/vue3-recommended',
+    'plugin:@typescript-eslint/recommended',
+    'prettier',
+    'plugin:prettier/recommended',
+    'plugin:jest/recommended',
   ],
   rules: {
-    "vue/script-setup-uses-vars": "error",
-    "@typescript-eslint/ban-ts-ignore": "off",
-    "@typescript-eslint/explicit-function-return-type": "off",
-    "@typescript-eslint/no-explicit-any": "off",
-    "@typescript-eslint/no-var-requires": "off",
-    "@typescript-eslint/no-empty-function": "off",
-    "vue/custom-event-name-casing": "off",
-    "no-use-before-define": "off",
-    "@typescript-eslint/no-use-before-define": "off",
-    "@typescript-eslint/ban-ts-comment": "off",
-    "@typescript-eslint/ban-types": "off",
-    "@typescript-eslint/no-non-null-assertion": "off",
-    "@typescript-eslint/explicit-module-boundary-types": "off",
-    "@typescript-eslint/no-unused-vars": [
-      "error",
+    'vue/script-setup-uses-vars': 'error',
+    '@typescript-eslint/ban-ts-ignore': 'off',
+    '@typescript-eslint/explicit-function-return-type': 'off',
+    '@typescript-eslint/no-explicit-any': 'off',
+    '@typescript-eslint/no-var-requires': 'off',
+    '@typescript-eslint/no-empty-function': 'off',
+    'vue/custom-event-name-casing': 'off',
+    'no-use-before-define': 'off',
+    '@typescript-eslint/no-use-before-define': 'off',
+    '@typescript-eslint/ban-ts-comment': 'off',
+    '@typescript-eslint/ban-types': 'off',
+    '@typescript-eslint/no-non-null-assertion': 'off',
+    '@typescript-eslint/explicit-module-boundary-types': 'off',
+    '@typescript-eslint/no-unused-vars': [
+      'error',
       {
-        argsIgnorePattern: "^_",
-        varsIgnorePattern: "^_",
+        argsIgnorePattern: '^_',
+        varsIgnorePattern: '^_',
       },
     ],
-    "no-unused-vars": [
-      "error",
+    'no-unused-vars': [
+      'error',
       {
-        argsIgnorePattern: "^_",
-        varsIgnorePattern: "^_",
+        argsIgnorePattern: '^_',
+        varsIgnorePattern: '^_',
       },
     ],
-    "space-before-function-paren": "off",
+    'space-before-function-paren': 'off',
 
-    "vue/attributes-order": "off",
-    "vue/one-component-per-file": "off",
-    "vue/html-closing-bracket-newline": "off",
-    "vue/max-attributes-per-line": "off",
-    "vue/multiline-html-element-content-newline": "off",
-    "vue/singleline-html-element-content-newline": "off",
-    "vue/attribute-hyphenation": "off",
-    "vue/require-default-prop": "off",
-    "vue/require-explicit-emits": "off",
-    "vue/no-useless-template-attributes": "off",
-    "vue/html-self-closing": [
-      "error",
+    'vue/attributes-order': 'off',
+    'vue/one-component-per-file': 'off',
+    'vue/html-closing-bracket-newline': 'off',
+    'vue/max-attributes-per-line': 'off',
+    'vue/multiline-html-element-content-newline': 'off',
+    'vue/singleline-html-element-content-newline': 'off',
+    'vue/attribute-hyphenation': 'off',
+    'vue/require-default-prop': 'off',
+    'vue/require-explicit-emits': 'off',
+    'vue/no-useless-template-attributes': 'off',
+    'vue/html-self-closing': [
+      'error',
       {
         html: {
-          void: "always",
-          normal: "never",
-          component: "always",
+          void: 'always',
+          normal: 'never',
+          component: 'always',
         },
-        svg: "always",
-        math: "always",
+        svg: 'always',
+        math: 'always',
       },
     ],
-    "vue/multi-word-component-names": "off",
+    'vue/multi-word-component-names': 'off',
   },
 });

+ 4 - 4
packages/commitlint-config.js

@@ -1,13 +1,13 @@
 module.exports = {
-  extends: ["cz"],
+  extends: ['cz'],
   parserPreset: {
     parserOpts: {
       headerPattern: /^(\w*)\(([\u4e00-\u9fa5]*)\)/,
-      headerCorrespondence: ["type", "scope"],
+      headerCorrespondence: ['type', 'scope'],
     },
   },
   rules: {
-    "type-empty": [2, "never"],
-    "scope-empty": [2, "never"],
+    'type-empty': [2, 'never'],
+    'scope-empty': [2, 'never'],
   },
 };

+ 7 - 6
package.json

@@ -16,20 +16,21 @@
   },
   "devDependencies": {
     "@commitlint/cli": "^17.1.2",
-    "@nighttrax/eslint-config-tsx": "~10.0.0-beta.0",
+    "@nighttrax/eslint-config-tsx": "~10.0.0",
     "commitizen": "^4.2.5",
     "commitlint-config-cz": "^0.13.3",
     "cz-customizable": "^7.0.0",
     "doctoc": "~2.2.0",
-    "eslint": "~8.23.0",
-    "eslint-plugin-import": "~2.26.0",
-    "husky": "^8.0.1",
-    "typescript": "~4.7.0",
+    "eslint": "~8.23.1",
     "eslint-config-prettier": "^8.5.0",
     "eslint-define-config": "^1.7.0",
+    "eslint-plugin-import": "~2.26.0",
     "eslint-plugin-jest": "^25.7.0",
     "eslint-plugin-prettier": "^4.2.1",
-    "eslint-plugin-vue": "^8.7.1"
+    "eslint-plugin-vue": "^8.7.1",
+    "husky": "^8.0.1",
+    "jest": "^29.0.3",
+    "typescript": "~4.7.4"
   },
   "config": {
     "commitizen": {

+ 1 - 1
packages/foo/package.json

@@ -14,6 +14,6 @@
   },
   "devDependencies": {
     "rimraf": "~3.0.2",
-    "typescript": "~4.7.0"
+    "typescript": "~4.7.4"
   }
 }

File diff ditekan karena terlalu besar
+ 3750 - 17343
pnpm-lock.yaml


+ 0 - 1
pnpm-workspace.yaml

@@ -1,3 +1,2 @@
 packages:
   - 'packages/**'
-  - 'apps/**'

+ 10 - 0
prettier.config.js

@@ -0,0 +1,10 @@
+module.exports = {
+  printWidth: 100,
+  semi: true,
+  vueIndentScriptAndStyle: true,
+  singleQuote: true,
+  trailingComma: 'all',
+  proseWrap: 'never',
+  htmlWhitespaceSensitivity: 'strict',
+  endOfLine: 'auto',
+};