From 845b848b60cd2356d9cf3b9d13c51595babaf72c Mon Sep 17 00:00:00 2001
From: 玲娜贝er <15891557205@163.com>
Date: 星期三, 27 十一月 2024 15:39:34 +0800
Subject: [PATCH] !159 eslint升级v9版本 * update: eslint升级v9版本 & 更新一些不符合校验规则的代码

---
 src/views/register.vue                     |    2 
 /dev/null                                  |   17 -----
 src/views/system/user/index.vue            |    4 
 eslint.config.js                           |   86 ++++++++++++++++++++++++++++
 package.json                               |   21 +++----
 src/views/system/user/profile/resetPwd.vue |    2 
 src/views/tool/gen/importTable.vue         |    2 
 src/layout/components/TopBar/search.vue    |    2 
 src/permission.ts                          |    2 
 9 files changed, 102 insertions(+), 36 deletions(-)

diff --git a/.eslintignore b/.eslintignore
deleted file mode 100644
index e74db40..0000000
--- a/.eslintignore
+++ /dev/null
@@ -1,17 +0,0 @@
-*.sh
-node_modules
-*.md
-*.woff
-*.ttf
-.vscode
-.idea
-dist
-/public
-/docs
-.husky
-.local
-/bin
-.eslintrc.cjs
-prettier.config.js
-src/assets
-tailwind.config.js
diff --git a/eslint.config.js b/eslint.config.js
new file mode 100644
index 0000000..8b67e9e
--- /dev/null
+++ b/eslint.config.js
@@ -0,0 +1,86 @@
+import globals from 'globals';
+import pluginJs from '@eslint/js';
+import tseslint from 'typescript-eslint';
+import pluginVue from 'eslint-plugin-vue';
+import { readFile } from 'node:fs/promises';
+import prettier from 'eslint-plugin-prettier';
+
+/**
+ * https://blog.csdn.net/sayUonly/article/details/123482912
+ * 鑷姩瀵煎叆鐨勯厤缃�
+ */
+const autoImportFile = new URL('./.eslintrc-auto-import.json', import.meta.url);
+const autoImportGlobals = JSON.parse(await readFile(autoImportFile, 'utf8'));
+
+/** @type {import('eslint').Linter.Config[]} */
+export default [
+  {
+    /**
+     * 涓嶉渶瑕�.eslintignore鏂囦欢 鑰屾槸鍦ㄨ繖閲岄厤缃�
+     */
+    ignores: [
+      '*.sh',
+      'node_modules',
+      '*.md',
+      '*.woff',
+      '*.ttf',
+      '.vscode',
+      '.idea',
+      'dist',
+      '/public',
+      '/docs',
+      '.husky',
+      '.local',
+      '/bin',
+      '.eslintrc.cjs',
+      'prettier.config.js',
+      'src/assets',
+      'tailwind.config.js'
+    ]
+  },
+  { files: ['**/*.{js,mjs,cjs,ts,vue}'] },
+  {
+    languageOptions: {
+      globals: globals.browser
+    }
+  },
+  pluginJs.configs.recommended,
+  ...tseslint.configs.recommended,
+  ...pluginVue.configs['flat/essential'],
+  {
+    files: ['**/*.vue'],
+    languageOptions: {
+      parserOptions: {
+        parser: tseslint.parser
+      }
+    }
+  },
+  {
+    languageOptions: {
+      globals: {
+        // 鑷姩瀵煎叆鐨勯厤缃� undef
+        ...autoImportGlobals.globals,
+        DialogOption: 'readonly',
+        LayoutSetting: 'readonly'
+      }
+    },
+    plugins: { prettier },
+    rules: {
+      '@typescript-eslint/no-empty-function': 'off',
+      '@typescript-eslint/no-explicit-any': 'off',
+      '@typescript-eslint/no-unused-vars': 'off',
+      '@typescript-eslint/no-this-alias': 'off',
+
+      // vue
+      'vue/multi-word-component-names': 'off',
+      'vue/valid-define-props': 'off',
+      'vue/no-v-model-argument': 'off',
+      'prefer-rest-params': 'off',
+      // prettier
+      'prettier/prettier': 'error',
+      // 鍏佽浣跨敤绌篛bject绫诲瀷 {}
+      '@typescript-eslint/no-empty-object-type': 'off',
+      '@typescript-eslint/no-unused-expressions': 'off'
+    }
+  }
+];
diff --git a/package.json b/package.json
index 9726ee5..04ca0b3 100644
--- a/package.json
+++ b/package.json
@@ -1,4 +1,5 @@
 {
+  "$schema": "https://json.schemastore.org/tsconfig",
   "name": "ruoyi-vue-plus",
   "version": "5.2.3",
   "description": "RuoYi-Vue-Plus澶氱鎴风鐞嗙郴缁�",
@@ -10,7 +11,8 @@
     "build:prod": "vite build --mode production",
     "build:dev": "vite build --mode development",
     "preview": "vite preview",
-    "lint:eslint": "eslint  --fix --ext .ts,.js,.vue ./src ",
+    "lint:eslint": "eslint",
+    "lint:eslint:fix": "eslint --fix",
     "prettier": "prettier --write ."
   },
   "repository": {
@@ -34,7 +36,7 @@
     "file-saver": "2.0.5",
     "fuse.js": "7.0.0",
     "highlight.js": "11.9.0",
-    "image-conversion": "^2.1.1",
+    "image-conversion": "2.1.1",
     "js-cookie": "3.0.5",
     "jsencrypt": "3.3.2",
     "nprogress": "0.2.0",
@@ -49,6 +51,7 @@
     "vxe-table": "4.5.22"
   },
   "devDependencies": {
+    "@eslint/js": "9.15.0",
     "@iconify/json": "2.2.276",
     "@intlify/unplugin-vue-i18n": "3.0.1",
     "@types/crypto-js": "4.2.2",
@@ -56,27 +59,22 @@
     "@types/js-cookie": "3.0.6",
     "@types/node": "18.18.2",
     "@types/nprogress": "0.2.3",
-    "@typescript-eslint/eslint-plugin": "7.18.0",
-    "@typescript-eslint/parser": "7.18.0",
     "@unocss/preset-attributify": "0.64.1",
     "@unocss/preset-icons": "0.64.1",
     "@unocss/preset-uno": "0.64.1",
     "@vitejs/plugin-vue": "5.0.4",
     "@vue/compiler-sfc": "3.4.23",
     "autoprefixer": "10.4.18",
-    "eslint": "8.57.0",
-    "eslint-config-prettier": "9.1.0",
-    "eslint-define-config": "2.1.0",
-    "eslint-plugin-import": "2.31.0",
-    "eslint-plugin-node": "11.1.0",
-    "eslint-plugin-prettier": "5.2.1",
-    "eslint-plugin-promise": "7.2.0",
+    "eslint": "9.15.0",
+    "eslint-plugin-prettier": "^5.2.1",
     "eslint-plugin-vue": "9.31.0",
     "fast-glob": "3.3.2",
+    "globals": "15.12.0",
     "postcss": "8.4.36",
     "prettier": "3.2.5",
     "sass": "1.72.0",
     "typescript": "5.7.2",
+    "typescript-eslint": "8.16.0",
     "unocss": "0.64.1",
     "unplugin-auto-import": "0.17.5",
     "unplugin-icons": "0.18.5",
@@ -86,7 +84,6 @@
     "vite-plugin-compression": "0.5.1",
     "vite-plugin-svg-icons": "2.0.1",
     "vitest": "1.5.0",
-    "vue-eslint-parser": "9.4.2",
     "vue-tsc": "2.0.13"
   }
 }
diff --git a/src/layout/components/TopBar/search.vue b/src/layout/components/TopBar/search.vue
index cf4b024..182e84a 100644
--- a/src/layout/components/TopBar/search.vue
+++ b/src/layout/components/TopBar/search.vue
@@ -66,7 +66,7 @@
   state.isShowSearch = false;
 };
 // 鑿滃崟鎼滅储鏁版嵁杩囨护
-const menuSearch = (queryString: string, cb: Function) => {
+const menuSearch = (queryString: string, cb: (options: any[]) => void) => {
   let options = state.menuList.filter((item) => {
     return item.title.indexOf(queryString) > -1;
   });
diff --git a/src/permission.ts b/src/permission.ts
index 125438b..51a928a 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -40,7 +40,7 @@
               router.addRoute(route); // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
             }
           });
-          // @ts-ignore
+          // @ts-expect-error hack鏂规硶 纭繚addRoutes宸插畬鎴�
           next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack鏂规硶 纭繚addRoutes宸插畬鎴�
         }
       } else {
diff --git a/src/views/register.vue b/src/views/register.vue
index 4e67a67..83f7a27 100644
--- a/src/views/register.vue
+++ b/src/views/register.vue
@@ -92,7 +92,7 @@
   password: [
     { required: true, trigger: 'blur', message: '璇疯緭鍏ユ偍鐨勫瘑鐮�' },
     { min: 5, max: 20, message: '鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿', trigger: 'blur' },
-    { pattern: /^[^<>"'|\\]+$/, message: '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\\ |', trigger: 'blur' }
+    { pattern: /^[^<>"'|\\]+$/, message: '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\ |', trigger: 'blur' }
   ],
   confirmPassword: [
     { required: true, trigger: 'blur', message: '璇峰啀娆¤緭鍏ユ偍鐨勫瘑鐮�' },
diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index d75e760..9597ca1 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -393,7 +393,7 @@
         message: '鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿',
         trigger: 'blur'
       },
-      { pattern: /^[^<>"'|\\]+$/, message: '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\\ |', trigger: 'blur' }
+      { pattern: /^[^<>"'|\\]+$/, message: '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\ |', trigger: 'blur' }
     ],
     email: [
       {
@@ -506,7 +506,7 @@
       inputErrorMessage: '鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿',
       inputValidator: (value) => {
         if (/<|>|"|'|\||\\/.test(value)) {
-          return '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\\ |';
+          return '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\ |';
         }
       }
     })
diff --git a/src/views/system/user/profile/resetPwd.vue b/src/views/system/user/profile/resetPwd.vue
index aae5ef8..3ca5ee9 100644
--- a/src/views/system/user/profile/resetPwd.vue
+++ b/src/views/system/user/profile/resetPwd.vue
@@ -45,7 +45,7 @@
       message: '闀垮害鍦� 6 鍒� 20 涓瓧绗�',
       trigger: 'blur'
     },
-    { pattern: /^[^<>"'|\\]+$/, message: '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\\ |', trigger: 'blur' }
+    { pattern: /^[^<>"'|\\]+$/, message: '涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > " \' \\ |', trigger: 'blur' }
   ],
   confirmPassword: [
     { required: true, message: '纭瀵嗙爜涓嶈兘涓虹┖', trigger: 'blur' },
diff --git a/src/views/tool/gen/importTable.vue b/src/views/tool/gen/importTable.vue
index e0f524e..f6e75cc 100644
--- a/src/views/tool/gen/importTable.vue
+++ b/src/views/tool/gen/importTable.vue
@@ -63,7 +63,7 @@
 
 /** 鏌ヨ鍙傛暟鍒楄〃 */
 const show = (dataName: string) => {
-  getDataNames().then(res => {
+  getDataNames().then((res) => {
     if (res.code == 200) {
       dataNameList.value = res.data;
       if (dataName) {

--
Gitblit v1.9.3