From bfc8e42bad6777243fdca9bf37b0d95a92c75159 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Fri, 10 May 2024 22:29:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=8D=A2=20ESLint=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=BA=20@antfu/eslint-config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 2 - .eslintrc.cjs | 68 - .prettierignore | 7 - .prettierrc.js | 14 - .vscode/settings.json | 52 +- README.md | 17 +- config/plugins/auto-import.ts | 2 +- config/plugins/components.ts | 2 +- config/plugins/svg-icon.ts | 2 +- eslint.config.js | 55 + package.json | 20 +- pnpm-lock.yaml | 9705 ++++++++++------- src/apis/area/index.ts | 4 +- src/apis/auth/index.ts | 2 +- src/apis/common/captcha.ts | 2 +- src/apis/common/common.ts | 4 +- src/apis/common/home.ts | 2 +- src/apis/monitor/log.ts | 2 +- src/apis/monitor/online.ts | 2 +- src/apis/system/dept.ts | 2 +- src/apis/system/dict.ts | 2 +- src/apis/system/file.ts | 2 +- src/apis/system/menu.ts | 2 +- src/apis/system/notice.ts | 2 +- src/apis/system/option.ts | 2 +- src/apis/system/role.ts | 2 +- src/apis/system/storage.ts | 2 +- src/apis/system/type.ts | 2 +- src/apis/system/user-center.ts | 8 +- src/apis/system/user.ts | 2 +- src/apis/tool/generator.ts | 2 +- src/components/Breadcrumb/index.vue | 2 +- src/components/GiCell/GiCellAvatar.vue | 12 +- src/components/GiCell/GiCellGender.vue | 8 +- src/components/GiCell/GiCellStatus.vue | 8 +- src/components/GiCell/GiCellTags.vue | 8 +- src/components/GiCodeView/index.vue | 9 +- src/components/GiDot/index.tsx | 2 +- src/components/GiFlexibleBox/index.vue | 14 +- src/components/GiFooter/index.vue | 4 +- src/components/GiForm/src/GiForm.vue | 6 +- src/components/GiForm/src/hooks.ts | 2 +- src/components/GiForm/src/type.ts | 14 +- src/components/GiIconSelector/index.vue | 18 +- src/components/GiOptionItem/index.vue | 14 +- src/components/GiOverFlowTags/index.vue | 6 +- src/components/GiSvgIcon/index.vue | 16 +- src/components/GiTable/index.vue | 31 +- src/components/GiTag/index.tsx | 2 +- src/components/JsonPretty/index.vue | 2 +- src/components/TextCopy/index.vue | 1 + src/constant/common.ts | 2 +- src/directives/permission/hasPerm.ts | 2 +- src/directives/permission/hasRole.ts | 2 +- src/hooks/app/useDept.ts | 2 +- src/hooks/app/useFormCurd.ts | 4 +- src/hooks/app/useMenu.ts | 2 +- src/hooks/modules/useBreakpoint.ts | 2 +- src/hooks/modules/useBreakpointIndex.ts | 2 +- src/hooks/modules/useDownload.ts | 18 +- src/hooks/modules/useRequest.ts | 2 +- src/hooks/modules/useTable.ts | 21 +- src/layout/LayoutMix.vue | 27 +- src/layout/components/Asider/index.vue | 2 +- .../HeaderRightBar/SettingDrawer.vue | 6 +- .../components/HeaderRightBar/index.vue | 7 +- src/layout/components/Logo.vue | 7 +- src/layout/components/Menu/MenuItem.vue | 10 +- src/layout/components/Menu/index.vue | 19 +- src/layout/components/MenuFoldBtn.vue | 2 +- src/layout/components/Tabs/index.vue | 18 +- src/main.ts | 18 +- src/mock/_data/_type.ts | 2 +- src/mock/area/index.ts | 4 +- src/router/index.ts | 2 +- src/router/permission.ts | 4 +- src/stores/modules/app.ts | 24 +- src/stores/modules/route.ts | 8 +- src/stores/modules/tabs.ts | 4 +- src/stores/modules/user.ts | 36 +- src/types/router.d.ts | 2 +- src/utils/downloadFile.ts | 4 +- src/utils/encrypt.ts | 6 +- src/utils/http.ts | 12 +- src/utils/index.ts | 67 +- src/utils/regexp.ts | 6 +- src/utils/validate.ts | 2 +- .../default/error/components/ErrorPage.vue | 7 +- src/views/default/redirect/index.vue | 2 +- src/views/home/components/AccessTrendCard.vue | 36 +- src/views/home/components/FastCard.vue | 2 +- src/views/home/components/MessageCard.vue | 2 +- src/views/home/components/NoticeCard.vue | 4 +- src/views/home/components/ProjectCard.vue | 2 +- src/views/home/components/WorkCard.vue | 2 +- src/views/login/components/account/index.vue | 77 +- src/views/login/components/email/index.vue | 5 +- src/views/login/components/phone/index.vue | 5 +- src/views/login/index.vue | 2 +- src/views/login/social/index.vue | 2 +- src/views/monitor/log/index.vue | 4 +- src/views/monitor/log/login/index.vue | 64 +- .../operation/OperationLogDetailDrawer.vue | 6 +- src/views/monitor/log/operation/index.vue | 64 +- src/views/monitor/online/index.vue | 41 +- src/views/setting/components/VerifyModel.vue | 16 +- src/views/setting/profile/BasicInfo.vue | 6 +- .../setting/profile/BasicInfoUpdateModal.vue | 4 +- src/views/setting/profile/Security.vue | 10 +- src/views/setting/profile/Social.vue | 17 +- .../system/config/components/BasicSetting.vue | 6 +- .../config/components/SecuritySetting.vue | 44 +- src/views/system/dept/DeptAddModal.vue | 16 +- src/views/system/dept/index.vue | 8 +- src/views/system/dict/DictAddModal.vue | 11 +- src/views/system/dict/index.vue | 42 +- .../system/dict/item/DictItemAddModal.vue | 11 +- src/views/system/dict/item/index.vue | 57 +- .../FileAudioModal/ModalContent.vue | 6 +- .../file/components/FileAudioModal/index.ts | 7 +- .../FileDetailModal/ModalContent.vue | 2 +- .../file/components/FileDetailModal/index.ts | 2 +- .../FileRenameModal/ModalContent.vue | 2 +- .../file/components/FileRenameModal/index.ts | 6 +- .../file/components/FileVideoModal/index.ts | 2 +- .../system/file/main/FileAsideStatistics.vue | 16 +- .../system/file/main/FileMain/FileList.vue | 16 +- src/views/system/file/main/FileMain/index.vue | 75 +- .../file/main/FileMain/useFileManage.ts | 2 +- src/views/system/menu/MenuAddModal.vue | 19 +- src/views/system/menu/index.vue | 6 +- src/views/system/notice/NoticeAddModal.vue | 15 +- src/views/system/notice/NoticeDetailModal.vue | 4 +- src/views/system/notice/index.vue | 44 +- src/views/system/role/RoleAddModal.vue | 15 +- src/views/system/role/RoleDetailDrawer.vue | 6 +- src/views/system/role/index.vue | 42 +- src/views/system/storage/StorageAddModal.vue | 17 +- src/views/system/storage/index.vue | 44 +- src/views/system/user/UserAddModal.vue | 15 +- src/views/system/user/UserDetailDrawer.vue | 2 +- src/views/system/user/UserResetPwdModal.vue | 11 +- src/views/system/user/index.vue | 49 +- src/views/tool/generator/GenConfigDrawer.vue | 19 +- src/views/tool/generator/GenPreviewModal.vue | 82 +- src/views/tool/generator/index.vue | 33 +- tsconfig.json | 29 +- vite.config.ts | 2 +- 148 files changed, 6982 insertions(+), 4714 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.cjs delete mode 100644 .prettierignore delete mode 100644 .prettierrc.js create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index db4c6d9b..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -dist -node_modules \ No newline at end of file diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 62ad3968..00000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,68 +0,0 @@ -/* eslint-env node */ -require('@rushstack/eslint-patch/modern-module-resolution') - -// @see https://eslint.bootcss.com/docs/rules/ -module.exports = { - root: true, - env: { - browser: true, - es2021: true, - node: true, - jest: true - }, - /* 指定如何解析语法 */ - parser: 'vue-eslint-parser', - /** 优先级低于 parse 的语法解析配置 */ - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - parser: '@typescript-eslint/parser', - jsxPragma: 'React', - ecmaFeatures: { - jsx: true - } - }, - /* 继承已有的规则(全部规则默认是关闭的, 这个配置项开启推荐规则, 推荐规则参照文档) */ - extends: [ - 'eslint:recommended', // 比如: 函数不能重名、对象不能出现重复key - 'plugin:vue/vue3-essential', // vue3语法规则 - 'plugin:vue/vue3-recommended', - '@vue/eslint-config-typescript/recommended', // ts语法规则 - '@vue/eslint-config-prettier' - ], - plugins: ['vue', '@typescript-eslint'], - /* - * "off" 或 0 ==> 关闭规则 - * "warn" 或 1 ==> 打开的规则作为警告(不影响代码执行) - * "error" 或 2 ==> 规则作为一个错误(代码不能执行,界面报错) - */ - rules: { - // eslint(https://eslint.bootcss.com/docs/rules/) - 'no-var': 'error', // 要求使用 let 或 const 而不是 var - 'no-multiple-empty-lines': ['warn', { max: 1 }], // 不允许多个空行 - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-unexpected-multiline': 'error', // 禁止空余的多行 - 'no-useless-escape': 'off', // 禁止不必要的转义字符 - - // typeScript (https://typescript-eslint.io/rules) - '@typescript-eslint/no-unused-vars': 'error', // 禁止定义未使用的变量 - '@typescript-eslint/prefer-ts-expect-error': 'error', // 禁止使用 @ts-ignore - '@typescript-eslint/no-explicit-any': 'off', // 禁止使用 any 类型 - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-namespace': 'off', // 禁止使用自定义 TypeScript 模块和命名空间 - '@typescript-eslint/semi': 'off', - - // eslint-plugin-vue (https://eslint.vuejs.org/rules/) - 'vue/multi-word-component-names': 'off', // 要求组件名称始终为 “-” 链接的单词 - 'vue/script-setup-uses-vars': 'error', // 防止 diff --git a/src/components/GiCell/GiCellGender.vue b/src/components/GiCell/GiCellGender.vue index 6a70fdfa..2b117b1a 100644 --- a/src/components/GiCell/GiCellGender.vue +++ b/src/components/GiCell/GiCellGender.vue @@ -15,13 +15,13 @@ diff --git a/src/components/GiCell/GiCellStatus.vue b/src/components/GiCell/GiCellStatus.vue index f441974a..449bc759 100644 --- a/src/components/GiCell/GiCellStatus.vue +++ b/src/components/GiCell/GiCellStatus.vue @@ -12,13 +12,13 @@ diff --git a/src/components/GiCell/GiCellTags.vue b/src/components/GiCell/GiCellTags.vue index 1d2c7bd5..b925a584 100644 --- a/src/components/GiCell/GiCellTags.vue +++ b/src/components/GiCell/GiCellTags.vue @@ -21,13 +21,13 @@ diff --git a/src/components/GiCodeView/index.vue b/src/components/GiCodeView/index.vue index 12ed8642..fe7c3b94 100644 --- a/src/components/GiCodeView/index.vue +++ b/src/components/GiCodeView/index.vue @@ -17,6 +17,10 @@ import { githubLight } from '@ddietr/codemirror-themes/github-light' import { oneDark } from '@codemirror/theme-one-dark' import { useAppStore } from '@/stores' +const props = withDefaults(defineProps(), { + type: 'javascript', + codeJson: '' +}) const appStore = useAppStore() const isDark = computed(() => appStore.theme === 'dark') @@ -24,11 +28,6 @@ interface Props { type?: 'javascript' | 'vue' codeJson: string } -const props = withDefaults(defineProps(), { - type: 'javascript', - codeJson: '' -}) - const defaultConfig = { tabSize: 2, basic: true, diff --git a/src/components/GiDot/index.tsx b/src/components/GiDot/index.tsx index bc2525cd..2f34771e 100644 --- a/src/components/GiDot/index.tsx +++ b/src/components/GiDot/index.tsx @@ -1,4 +1,4 @@ -import { defineComponent, type PropType } from 'vue' +import { type PropType, defineComponent } from 'vue' import './dot.scss' type TPropsType = 'primary' | 'success' | 'warning' | 'danger' | 'info' diff --git a/src/components/GiFlexibleBox/index.vue b/src/components/GiFlexibleBox/index.vue index 70361394..458157d8 100644 --- a/src/components/GiFlexibleBox/index.vue +++ b/src/components/GiFlexibleBox/index.vue @@ -9,22 +9,22 @@ import type { CSSProperties } from 'vue' defineOptions({ name: 'GiFlexibleBox' }) -interface Props { - modelValue: boolean - direction: 'left' | 'right' -} - const props = withDefaults(defineProps(), { modelValue: false, direction: 'right' }) +interface Props { + modelValue: boolean + direction: 'left' | 'right' +} + const BoxRef = ref() const style = computed(() => { const obj: CSSProperties = {} - obj[`margin-${props.direction}`] = - !props.modelValue && BoxRef.value && BoxRef.value.clientWidth ? `-${BoxRef.value.clientWidth}px` : 0 + obj[`margin-${props.direction}`] + = !props.modelValue && BoxRef.value && BoxRef.value.clientWidth ? `-${BoxRef.value.clientWidth}px` : 0 return obj }) diff --git a/src/components/GiFooter/index.vue b/src/components/GiFooter/index.vue index da3d327e..4d243922 100644 --- a/src/components/GiFooter/index.vue +++ b/src/components/GiFooter/index.vue @@ -5,9 +5,9 @@ diff --git a/src/components/GiSvgIcon/index.vue b/src/components/GiSvgIcon/index.vue index f6a6c67d..5b90a35c 100644 --- a/src/components/GiSvgIcon/index.vue +++ b/src/components/GiSvgIcon/index.vue @@ -3,7 +3,7 @@ aria-hidden="true" :class="svgClass" v-bind="$attrs" - :style="{ color: color, fill: color, width: iconSize, height: iconSize }" + :style="{ color, fill: color, width: iconSize, height: iconSize }" > @@ -12,21 +12,21 @@ diff --git a/src/views/home/components/AccessTrendCard.vue b/src/views/home/components/AccessTrendCard.vue index 74cf4f77..b2c9aa63 100644 --- a/src/views/home/components/AccessTrendCard.vue +++ b/src/views/home/components/AccessTrendCard.vue @@ -13,11 +13,28 @@ diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index c090525a..85d778d9 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -9,8 +9,8 @@ :loading="loading" :scroll="{ x: '100%', y: '100%', minWidth: 1000 }" :pagination="false" - :disabledTools="['size']" - :disabledColumnKeys="['name']" + :disabled-tools="['size']" + :disabled-column-keys="['name']" @refresh="search" > diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index 50ecc4d2..46cda5a9 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -8,8 +8,8 @@ :loading="loading" :scroll="{ x: '100%', y: '100%', minWidth: 1000 }" :pagination="pagination" - :disabledTools="['size']" - :disabledColumnKeys="['name']" + :disabled-tools="['size']" + :disabled-column-keys="['name']" @refresh="search" > diff --git a/src/views/system/dict/item/index.vue b/src/views/system/dict/item/index.vue index 21dd351e..e340b476 100644 --- a/src/views/system/dict/item/index.vue +++ b/src/views/system/dict/item/index.vue @@ -1,7 +1,7 @@ diff --git a/src/views/system/role/RoleDetailDrawer.vue b/src/views/system/role/RoleDetailDrawer.vue index c968a52f..e7df1ad1 100644 --- a/src/views/system/role/RoleDetailDrawer.vue +++ b/src/views/system/role/RoleDetailDrawer.vue @@ -22,7 +22,6 @@ > diff --git a/src/views/system/storage/index.vue b/src/views/system/storage/index.vue index df043d81..8eaeb5de 100644 --- a/src/views/system/storage/index.vue +++ b/src/views/system/storage/index.vue @@ -8,8 +8,8 @@ :loading="loading" :scroll="{ x: '100%', y: '100%', minWidth: 1300 }" :pagination="pagination" - :disabledTools="['size']" - :disabledColumnKeys="['name']" + :disabled-tools="['size']" + :disabled-column-keys="['name']" @refresh="search" > diff --git a/src/views/system/user/UserDetailDrawer.vue b/src/views/system/user/UserDetailDrawer.vue index 54c367f6..e3f36fb5 100644 --- a/src/views/system/user/UserDetailDrawer.vue +++ b/src/views/system/user/UserDetailDrawer.vue @@ -27,8 +27,8 @@ diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index cf538f62..2eca35d0 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -19,15 +19,14 @@ diff --git a/src/views/tool/generator/GenPreviewModal.vue b/src/views/tool/generator/GenPreviewModal.vue index 07f7bda7..f802734f 100644 --- a/src/views/tool/generator/GenPreviewModal.vue +++ b/src/views/tool/generator/GenPreviewModal.vue @@ -39,9 +39,9 @@