import js from "@eslint/js"; import globals from "globals"; import reactHooks from "eslint-plugin-react-hooks"; import reactRefresh from "eslint-plugin-react-refresh"; import tseslint from "typescript-eslint"; export default tseslint.config( { ignores: ["dist"] }, { extends: [js.configs.recommended, ...tseslint.configs.strict], files: ["**/*.{ts,tsx}"], languageOptions: { ecmaVersion: 2022, globals: globals.browser, }, plugins: { "react-hooks": reactHooks, "react-refresh": reactRefresh, }, rules: { ...reactHooks.configs.recommended.rules, "react-refresh/only-export-components": ["warn", { allowConstantExport: true }], // 禁 console.log(允许 warn/error) "no-console": ["error", { allow: ["warn", "error"] }], // 禁 any "@typescript-eslint/no-explicit-any": "error", // 命名约定 "@typescript-eslint/naming-convention": [ "error", { selector: "variable", format: ["camelCase", "UPPER_CASE", "PascalCase"] }, { selector: "function", format: ["camelCase", "PascalCase"] }, { selector: "typeLike", format: ["PascalCase"] }, ], // 单文件行数上限 "max-lines": ["warn", { max: 200, skipBlankLines: true, skipComments: true }], }, } );