Files
tashow-h5/eslint.config.js
2025-09-05 15:18:10 +08:00

112 lines
2.3 KiB
JavaScript

// import antfu from "@antfu/eslint-config";
// export default antfu({
// vue: false,
// react: true, // @eslint-react/eslint-plugin
// typescript: true,
// stylistic: true,
// formatters: true, // eslint-plugin-format 格式化
// rules: {
// "react/no-array-index-key": "off",
// "react/no-children-to-array": "off",
// "jsdoc/check-alignment": "off",
// "react-hooks/exhaustive-deps": "off",
// },
// });
// eslint.config.js
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
export default [
// 忽略文件
{
ignores: [
"dist/**",
"node_modules/**",
"packages/*/dist/**",
"projects/*/dist/**",
"**/*.config.js",
"**/*.config.ts",
],
},
// 基础 JavaScript 配置
{
files: ["**/*.{js,jsx,ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
sourceType: "module",
globals: {
...globals.browser,
...globals.es2020,
...globals.node,
},
},
rules: {
...js.configs.recommended.rules,
},
},
// TypeScript 配置
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"@typescript-eslint": tsPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_" },
],
"@typescript-eslint/no-explicit-any": "warn",
},
},
// React 配置
{
files: ["**/*.{jsx,tsx}"],
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
// 项目特定规则
{
files: ["projects/**/*.{ts,tsx}"],
rules: {
"no-console": "off",
},
},
// 包特定规则
{
files: ["packages/**/*.{ts,tsx}"],
rules: {
"no-console": "warn",
},
},
];