Procházet zdrojové kódy

feat: 添加TypeScript ESLint支持并扩展订单表单类型

yz před 1 týdnem
rodič
revize
8a510bc55d
4 změnil soubory, kde provedl 1164 přidání a 128 odebrání
  1. 19 2
      .eslintrc.js
  2. 1134 122
      package-lock.json
  3. 6 1
      package.json
  4. 5 3
      src/components/order-form/types.d.ts

+ 19 - 2
.eslintrc.js

@@ -7,12 +7,29 @@ module.exports = {
     'plugin:vue/essential',
     'eslint:recommended'
   ],
+  plugins: ['@typescript-eslint'],
   rules: {
     'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
     'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
     "no-unused-vars":"off" //关闭声明后未被使用的变量或参数
   },
   parserOptions: {
-    parser: 'babel-eslint'
-  }
+    parser: 'babel-eslint',
+    ecmaVersion: 2020,
+    sourceType: 'module'
+  },
+  overrides: [
+    {
+      files: ['*.ts', '*.tsx'],
+      parser: '@typescript-eslint/parser',
+      extends: [
+        'plugin:@typescript-eslint/recommended'
+      ],
+      parserOptions: {
+        ecmaVersion: 2020,
+        sourceType: 'module',
+        project: './tsconfig.json'
+      }
+    }
+  ]
 }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1134 - 122
package-lock.json


+ 6 - 1
package.json

@@ -45,16 +45,21 @@
     "@babel/plugin-proposal-optional-chaining": "^7.21.0",
     "@types/axios": "^0.14.4",
     "@types/webpack-env": "^1.18.8",
+    "@typescript-eslint/eslint-plugin": "^5.62.0",
+    "@typescript-eslint/parser": "^5.62.0",
     "@vue/cli-plugin-babel": "^3.1.1",
     "@vue/cli-plugin-eslint": "^3.1.5",
     "@vue/cli-service": "^3.1.4",
     "chai": "^4.1.2",
+    "eslint": "^8.57.0",
+    "eslint-plugin-vue": "^9.0.0",
     "image-webpack-loader": "^8.1.0",
     "node-sass": "^4.12.0",
     "null-loader": "^4.0.1",
     "sass-loader": "^7.0.1",
     "ts-loader": "^8.4.0",
-    "typescript": "^5.9.2",
+    "typescript": "^5.1.6",
+    "vue-eslint-parser": "^9.0.0",
     "vue-template-compiler": "^2.5.17",
     "webpack-bundle-analyzer": "^3.0.3"
   },

+ 5 - 3
src/components/order-form/types.d.ts

@@ -69,6 +69,8 @@ export interface OrderFormModel {
   orgCode: string;
   /** 组织名称 */
   orgName: string;
+  /** 客户ID */
+  customerId: string | number | null;
   /** 客户编码 */
   customerCode: string;
   /** 客户名称 */
@@ -79,6 +81,8 @@ export interface OrderFormModel {
   totalAmount: number | null;
   /** 订单总数量 */
   totalQuantity: number | null;
+  /** 地址ID */
+  addressId: string | number | null;
   /** 收货人姓名 */
   receiverName: string;
   /** 收货人电话 */
@@ -94,9 +98,7 @@ export interface OrderFormModel {
 /**
  * 订单表单验证规则类型
  */
-export type OrderFormRules = {
-  [K in keyof OrderFormModel]?: ValidationRule[];
-};
+export type OrderFormRules = Partial<Record<keyof OrderFormModel, ValidationRule[]>>;
 
 /**
  * 下拉选择器选项接口

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů