Files
labelmain/eslint.config.mjs
2026-04-20 20:31:32 +08:00

75 lines
2.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { FlatCompat } from "@eslint/eslintrc"
import tseslint from "@typescript-eslint/eslint-plugin"
import tsparser from "@typescript-eslint/parser"
import prettierPlugin from "eslint-plugin-prettier"
import { dirname } from "path"
import { fileURLToPath } from "url"
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
})
const eslintConfig = [
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
...compat.extends("next/core-web-vitals"),
{
languageOptions: {
parser: tsparser,
parserOptions: {
sourceType: "module",
ecmaVersion: "latest",
},
},
plugins: {
"@typescript-eslint": tseslint,
prettier: prettierPlugin,
},
rules: {
// "no-console": "error",
// 'prettier/prettier': 'warn',
"no-var": "error", // 要求使用 let 或 const 而不是 var
eqeqeq: [2, "allow-null"], // 使用 === 替代 ==
"no-multiple-empty-lines": ["error", { max: 1 }], // 不允许多个空行
"no-multi-spaces": 2, // 不能用多余的空格
"no-trailing-spaces": 2, // 一行结束后面不要有空格
"no-use-before-define": "off", // 禁止在 函数/类/变量 定义之前使用它们
"prefer-const": "off", // 此规则旨在标记使用 let 关键字声明但在初始分配后从未重新分配的变量,要求使用 const
"no-irregular-whitespace": "off", // 禁止不规则的空白
"prettier/prettier": [
"error",
{
endOfLine: "auto",
},
],
"react-hooks/rules-of-hooks": "error", // 检查 Hooks 的声明
"react-hooks/exhaustive-deps": "warn", // 检查依赖项的声明
"react-hooks/immutability": "off", // 现有交互层大量依赖 ref/mutable 对象,暂不启用 React Compiler 约束
"react-hooks/preserve-manual-memoization": "off", // 当前项目未接入 React Compiler先保留现有 useCallback/useMemo 依赖写法
"react-hooks/refs": "off", // 现有画布能力通过 ref 暴露 imperative API后续如接入 Compiler 再系统治理
"react-hooks/set-state-in-effect": "off", // 页面初始化和同步逻辑仍依赖 effect 驱动,避免一次升级触发大规模重构
"react-hooks/static-components": "off", // 先允许局部 render helper后续再按需拆分组件
"react/display-name": "off",
"import/no-anonymous-default-export": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
},
], // 禁止定义未使用的变量
},
},
]
export default eslintConfig