64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
import { defineConfig, globalIgnores } from "eslint/config";
|
||
import nextVitals from "eslint-config-next/core-web-vitals";
|
||
import nextTs from "eslint-config-next/typescript";
|
||
|
||
const eslintConfig = defineConfig([
|
||
...nextVitals,
|
||
...nextTs,
|
||
// Override default ignores of eslint-config-next.
|
||
globalIgnores([
|
||
// Default ignores of eslint-config-next:
|
||
".next/**",
|
||
"out/**",
|
||
"build/**",
|
||
"next-env.d.ts",
|
||
|
||
// 构建/生成/第三方产物(不参与 lint)
|
||
"coverage/**",
|
||
"public/**",
|
||
"local-packages/**",
|
||
"**/.prisma/**",
|
||
"**/*.min.js",
|
||
"**/*.wasm",
|
||
|
||
// 忽略测试文件
|
||
"tests/**",
|
||
"**/*.test.ts",
|
||
"**/*.test.tsx",
|
||
// 忽略有 React Compiler 问题的文件(后续优化)
|
||
"src/components/ui/Modal.tsx",
|
||
"src/hooks/useAuth.ts",
|
||
"src/hooks/usePerformance.ts",
|
||
]),
|
||
// 自定义规则
|
||
{
|
||
rules: {
|
||
// 允许使用 any 类型(后续逐步优化)
|
||
"@typescript-eslint/no-explicit-any": "warn",
|
||
// 允许未使用的变量(以下划线开头的除外)
|
||
"@typescript-eslint/no-unused-vars": ["warn", {
|
||
"argsIgnorePattern": "^_",
|
||
"varsIgnorePattern": "^_"
|
||
}],
|
||
// 允许使用 @ts-ignore(建议使用 @ts-expect-error)
|
||
"@typescript-eslint/ban-ts-comment": "warn",
|
||
// 允许 require 导入
|
||
"@typescript-eslint/no-require-imports": "warn",
|
||
// 允许匿名默认导出
|
||
"import/no-anonymous-default-export": "warn",
|
||
// 允许空接口(用于扩展)
|
||
"@typescript-eslint/no-empty-object-type": "warn",
|
||
// 允许未转义的引号
|
||
"react/no-unescaped-entities": "warn",
|
||
// React Hooks 规则降级为警告(兼容现有代码模式)
|
||
"react-hooks/exhaustive-deps": "warn",
|
||
// 该规则对“Effect 内更新 UI 状态”的场景过于严格,先降级为警告
|
||
"react-hooks/set-state-in-effect": "warn",
|
||
// 3D/动画场景需要对 three.js/DOM 进行可控变更;该规则过于严格,先降级为警告
|
||
"react-hooks/immutability": "warn",
|
||
}
|
||
}
|
||
]);
|
||
|
||
export default eslintConfig;
|