From 2005e8c11b8dba19a58728685b9abe20c81819e0 Mon Sep 17 00:00:00 2001 From: Lexcubia Date: Mon, 28 Apr 2025 16:11:23 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E6=B7=BB=E5=8A=A0=20ESLint=20?= =?UTF-8?q?=E5=92=8C=20Prettier=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 .eslintrc.js 配置 ESLint 规则,包括 Vue、TypeScript 和 Prettier 插件 - 新增 .prettierrc 配置 Prettier 格式化规则 - 设置合适的代码风格和警告级别,以提高代码质量和一致性 --- .eslintrc.js | 36 ++++++++++++++++++++++++++++++++++++ .prettierrc | 13 +++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .eslintrc.js create mode 100644 .prettierrc diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..3be0965 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,36 @@ +module.exports = { + root: true, + env: { + node: true, + browser: true, + es2021: true + }, + extends: [ + 'plugin:vue/vue3-recommended', + 'eslint:recommended', + '@vue/typescript/recommended', + '@vue/prettier', + '@vue/prettier/@typescript-eslint' + ], + parserOptions: { + ecmaVersion: 2021 + }, + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'vue/multi-word-component-names': 'off', + 'vue/no-v-html': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + 'prettier/prettier': [ + 'warn', + { + semi: false, + singleQuote: true, + printWidth: 300, + trailingComma: 'none', + arrowParens: 'avoid' + } + ] + } +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..bb17a1e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,13 @@ +{ + "semi": false, + "singleQuote": true, + "printWidth": 300, + "trailingComma": "none", + "arrowParens": "avoid", + "endOfLine": "auto", + "tabWidth": 2, + "useTabs": false, + "bracketSpacing": true, + "jsxBracketSameLine": false, + "vueIndentScriptAndStyle": true +}