diff --git a/.eslintrc.js b/.eslintrc.js index f2744021..881fe12d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -20,7 +20,7 @@ module.exports = { }, ecmaVersion: 12, sourceType: 'module', - project: './tsconfig.json' // 指定 tsconfig.json 的路径 + project: './tsconfig.eslint.json' // 指向新的 ESLint 配置文件 }, plugins: [ 'react', @@ -42,6 +42,26 @@ module.exports = { '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], // 确保未使用的变量报错 '@typescript-eslint/explicit-function-return-type': 'off' // 关闭强制函数返回类型声明 }, + overrides: [ + { + files: ['.eslintrc.js'], + parser: null // 避免对 `.eslintrc.js` 文件使用 TypeScript 解析器 + }, + { + files: ['**/*.js'], // Match all .js files 对js的代码规范检查不那么严格 + rules: { + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/no-floating-promises': 'off' + } + } + ], globals: { React: true } diff --git a/middleware.ts b/middleware.ts index 03ebb331..0ae00a72 100644 --- a/middleware.ts +++ b/middleware.ts @@ -27,6 +27,7 @@ const isTenantAdminRoute = createRouteMatcher([ * @param ev * @returns */ +// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars const noAuthMiddleware = async (req: any, ev: any) => { // 如果没有配置 Clerk 相关环境变量,返回一个默认响应或者继续处理请求 return NextResponse.next() diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 00000000..b6bbb654 --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "include": [".eslintrc.js", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"] +} diff --git a/tsconfig.json b/tsconfig.json index 5d04ae0f..fe258e69 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,6 +24,13 @@ "isolatedModules": true, "jsx": "preserve" }, - "include": ["next-env.d.ts", "**/*.js", "**/*.ts", "**/*.tsx", "**/*.jsx"], + "include": [ + "next-env.d.ts", + "**/*.js", + "**/*.ts", + "**/*.tsx", + "**/*.jsx", + ".eslintrc.js" + ], "exclude": ["node_modules"] }