-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy patheslint.config.js
141 lines (132 loc) · 4.14 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// eslint.config.js
import js from "@eslint/js";
import globals from "globals";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import jsxA11y from "eslint-plugin-jsx-a11y";
import prettier from "eslint-plugin-prettier";
import prettierConfig from "eslint-config-prettier";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import tailwindcss from "eslint-plugin-tailwindcss";
import simpleImportSort from "eslint-plugin-simple-import-sort";
export default [
// Base configuration and ignores
{
ignores: [
"dist",
"node_modules",
"build",
"eslint.config.js",
"tailwind.config.js",
"postcss.config.js",
"tsconfig.*.json",
"vitest.setup.ts",
],
},
// TypeScript and React configurations
{
files: ["**/*.{js,jsx,ts,tsx}"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: tsParser,
globals: {
...globals.browser,
...globals.node,
},
parserOptions: {
ecmaFeatures: { jsx: true },
project: ["tsconfig.node.json", "tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
react: {
version: "detect",
},
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
typescript: {
project: "./tsconfig.app.json",
},
},
},
plugins: {
react,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
tailwindcss,
"simple-import-sort": simpleImportSort,
"jsx-a11y": jsxA11y,
prettier,
"@typescript-eslint": tsPlugin,
},
rules: {
// Base ESLint recommended rules
...js.configs.recommended.rules,
// React and React Hooks recommended rules
...react.configs.recommended.rules,
...react.configs["jsx-runtime"].rules,
...reactHooks.configs.recommended.rules,
// Import plugin recommended rules
"simple-import-sort/imports": [
"error",
{
groups: [
// Built-in modules (e.g., fs, path) come first
["^node:?", "^[a-z]"],
// External packages (e.g., react, lodash)
["^@?\\w"],
// Internal aliases (e.g., @components, @utils)
["^@/"],
// Parent imports (e.g., ../)
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Sibling imports (e.g., ./)
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports (e.g., .css, .scss)
["^.+\\.?(css|scss|sass|less)$"],
],
},
],
"simple-import-sort/exports": "error",
// JSX Accessibility recommended rules
...jsxA11y.configs.recommended.rules,
// Disable rules that conflict with Prettier
...prettierConfig.rules,
// TypeScript and additional custom rules
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
},
],
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
// tailwindcss plugin rules
"tailwindcss/classnames-order": "warn",
"tailwindcss/no-custom-classname": "off",
// Other custom rules
"react/jsx-no-target-blank": "off",
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"react/react-in-jsx-scope": "off",
"react/jsx-uses-react": "off",
"prettier/prettier": ["error"],
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"react/jsx-props-no-spreading": "off",
"no-restricted-syntax": [
"error",
{
selector: "OptionalMemberExpression",
message: "Avoid using optional chaining unless necessary.",
},
],
"jsx-a11y/anchor-is-valid": "off",
},
},
];