From 236df6294a806ed5a7bf64535c921849cf48b682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AE=E6=AD=A2?= <15385428+Fuzhibin2@user.noreply.gitee.com> Date: Thu, 23 Jan 2025 05:51:21 +0000 Subject: [PATCH 1/2] update CONTRIBUTING.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 浮止 <15385428+Fuzhibin2@user.noreply.gitee.com> --- CONTRIBUTING.md | 128 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 363f33c..271b76a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,11 +56,96 @@ function processData(data: any) { } ``` +#### ESLint 规范 + +- 使用项目配置的 ESLint 规则 +- 在提交代码前运行 ESLint 检查 +- 修复所有 ESLint 错误和警告 + +```typescript +// ESLint 配置示例 +module.exports = { + root: true, + env: { + browser: true, + node: true, + }, + extends: [ + "plugin:vue/vue3-recommended", + "plugin:@typescript-eslint/recommended", + "@vue/typescript/recommended", + "prettier", + ], + parser: "vue-eslint-parser", + parserOptions: { + ecmaVersion: 2022, + parser: "@typescript-eslint/parser", + sourceType: "module", + }, + rules: { + // Vue 3 规则 + "vue/script-setup-uses-vars": "error", + "vue/no-unused-vars": "error", + "vue/multi-word-component-names": "error", + "vue/component-tags-order": [ + "error", + { + order: ["script", "template", "style"], + }, + ], + + // TypeScript 规则 + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + }, + ], + + // 通用规则 + "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", + "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", + "prefer-const": "error", + "no-var": "error", + eqeqeq: ["error", "always"], + }, +}; +``` + +常见 ESLint 规则说明: + +- `vue/script-setup-uses-vars`: 确保 `