From fccf4000c66de99c07b20328be6dba6f0d24f6ed Mon Sep 17 00:00:00 2001 From: Kirk Lin Date: Tue, 2 Jul 2024 18:09:40 +0800 Subject: [PATCH] style: fix lint --- .eslintrc | 11 - .github/CODE_OF_CONDUCT.md | 28 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .vscode/settings.json | 50 +- eslint.config.mjs | 26 + index.html | 11 +- package.json | 3 +- pnpm-lock.yaml | 1211 +++++++---------- src/components/Icon/UnoCSSIconButton.vue | 3 +- src/components/README.md | 1 - src/composables/useMobileCode.ts | 4 +- src/layouts/Container/index.vue | 2 +- src/layouts/Navbar/index.vue | 22 +- src/pages/login/index.vue | 6 +- src/pages/user/index.vue | 10 +- src/request/src/CheckStatus.ts | 2 +- src/request/src/axiosCancel.ts | 4 +- .../src/options/transform/defaultTransform.ts | 3 +- src/request/src/utils.ts | 4 +- src/store/plugin/persist.ts | 4 +- src/styles/main.scss | 10 +- src/styles/variables.scss | 22 +- src/utils/src/__test__/dateUtil.test.ts | 12 +- src/utils/src/__test__/deepMerge.test.ts | 16 +- src/utils/src/__test__/snowflake.test.ts | 4 +- src/utils/src/__test__/treeHelper.test.ts | 5 +- src/utils/src/__test__/utils.test.ts | 8 +- src/utils/src/browserHelper.ts | 10 +- src/utils/src/cipher.ts | 6 +- src/utils/src/config.ts | 2 +- src/utils/src/domUtils.ts | 14 +- src/utils/src/mitt.ts | 11 +- src/utils/src/rules.ts | 4 +- src/utils/src/typeChecks.ts | 6 +- src/utils/src/util.ts | 5 +- src/utils/src/vue/install.ts | 22 +- tsconfig.json | 14 +- types/env.d.ts | 4 +- 38 files changed, 721 insertions(+), 861 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 90d2f69..0000000 --- a/.eslintrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": [ - "@kirklin" - ], - "rules": { - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off" - } -} diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 00c616c..bfa5870 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Our Responsibilities @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team. +reported by contacting the project team. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 23fa589..2157ce5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,6 +11,7 @@ Before submitting the PR, please make sure you do the following: - Added necessary documentation (if appropriate) --> + ## Proposed changes @@ -27,7 +28,6 @@ _Put an `x` in the boxes that apply_ ## Linked Issues - ## Further comments diff --git a/.vscode/settings.json b/.vscode/settings.json index 61ff277..317284b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,29 +1,49 @@ { + // 禁用默认的格式化程序,改用ESLint进行格式化 + "prettier.enable": false, "editor.formatOnSave": false, + + // 自动修复 "editor.codeActionsOnSave": { - "source.fixAll": false, - "source.fixAll.eslint": true, // this allows ESLint to auto fix on save - "source.organizeImports": false - }, - // ESLint config: https://github.com/kirklin/eslint-config - "eslint.codeAction.showDocumentation": { - "enable": true + "source.fixAll.eslint": "explicit", + "source.organizeImports": "never" }, - "eslint.quiet": true, + + // 在IDE中隐藏样式规则的提示,但仍然自动修复它们 + "eslint.rules.customizations": [ + { "rule": "style/*", "severity": "off" }, + { "rule": "format/*", "severity": "off" }, + { "rule": "*-indent", "severity": "off" }, + { "rule": "*-spacing", "severity": "off" }, + { "rule": "*-spaces", "severity": "off" }, + { "rule": "*-order", "severity": "off" }, + { "rule": "*-dangle", "severity": "off" }, + { "rule": "*-newline", "severity": "off" }, + { "rule": "*quotes", "severity": "off" }, + { "rule": "*semi", "severity": "off" } + ], + + // 为所有支持的语言启用ESLint "eslint.validate": [ "javascript", - "typescript", "javascriptreact", + "typescript", "typescriptreact", "vue", "html", "markdown", "json", "jsonc", - "json5" - ], - "prettier.enable": false, - "prettier.printWidth": 200, - "prettier.semi": true, - "prettier.singleQuote": false + "yaml", + "toml", + "xml", + "gql", + "graphql", + "astro", + "css", + "less", + "scss", + "pcss", + "postcss" + ] } diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..30d5159 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,26 @@ +import kirklin from "@kirklin/eslint-config"; + +export default kirklin({ + rules: { + "node/prefer-global/process": "off", + "no-console": "warn", + }, + formatters: { + /** + * 格式化CSS、LESS、SCSS文件,以及Vue中的` diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 52f79bf..256618d 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -18,13 +18,13 @@ const loginFormData = shallowReactive({ const isPasswordLogin = ref(true); const smsCode = ref(""); -const handleLogin = async () => { +async function handleLogin() { if (!loginFormData.agree) { return showToast("请勾选协议"); } showSuccessToast("登录成功"); await router.replace("/home"); -}; +} // 发送短信验证码 const { sendMobileCode, countdownValue, formRef } = useMobileCode( @@ -103,5 +103,5 @@ const { sendMobileCode, countdownValue, formRef } = useMobileCode( diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue index 1f7dc4f..492b218 100644 --- a/src/pages/user/index.vue +++ b/src/pages/user/index.vue @@ -20,13 +20,13 @@ const tools = [ { label: "系统设置", path: "/user" }, ]; const router = useRouter(); -const handleLogout = async () => { +async function handleLogout() { await showConfirmDialog({ title: "温馨提示", message: "您是否确认退出APP?", }); await router.push("/login"); -}; +}