-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.js
More file actions
188 lines (182 loc) · 4.6 KB
/
eslint.config.js
File metadata and controls
188 lines (182 loc) · 4.6 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import js from "@eslint/js";
import eslintPluginVitest from "@vitest/eslint-plugin";
import { defineConfig } from "eslint/config";
import eslintConfigPrettier from "eslint-config-prettier/flat";
import eslintPluginImport from "eslint-plugin-import";
import eslintPluginJsonc from "eslint-plugin-jsonc";
import packageJsonPlugin from "eslint-plugin-package-json";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import globals from "globals";
import * as tseslint from "typescript-eslint";
const IGNORE_PATTERNS = [
// Build artifacts and generated files
"dist/**",
// Configuration and metadata
"*.config.ts",
"CHANGELOG.md",
"package-lock.json",
// Directories
".husky/**",
".vscode/**",
".idea/**",
".github/**",
"**/node_modules/**",
"**/docs/**",
// System files
".DS_Store",
];
export default defineConfig([
{
// For faster linting
ignores: IGNORE_PATTERNS,
},
// Base JS/TS configuration
{
files: ["**/*.{js,ts,tsx,jsx}"],
extends: [js.configs.recommended],
languageOptions: {
ecmaVersion: 2020,
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
"no-console": ["warn", { allow: ["warn", "error", "info"] }],
"no-unused-vars": "off", // Handled by TypeScript
},
},
// TypeScript specific configuration
{
files: ["**/*.{ts,tsx}"],
extends: [...tseslint.configs.recommended],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
project: "./tsconfig.json",
},
},
rules: {
...tseslint.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "warn",
},
},
// React specific configuration
{
files: ["**/*.{jsx,tsx}"],
plugins: {
react: reactPlugin,
"react-hooks": reactHooksPlugin,
},
settings: {
react: {
version: "detect",
},
},
rules: {
"react/prop-types": "off", // Not needed with TypeScript
"react/react-in-jsx-scope": "off", // Not needed with newer React
"react/jsx-uses-react": "off", // Not needed with newer React
"react/jsx-no-undef": "error",
"react/jsx-no-duplicate-props": "error",
"react/jsx-key": "error",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
},
},
// Import plugin configuration
{
files: ["**/*.{js,ts,tsx,jsx}"],
plugins: {
import: eslintPluginImport,
},
settings: {
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
},
rules: {
"import/order": [
"warn",
{
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"import/no-duplicates": "error",
},
},
// Vitest configuration for test files
{
files: ["src/**/*.{test.ts,test.tsx}", "src/vitest.setup.ts"],
languageOptions: {
parser: tseslint.parser,
globals: {
...globals.vitest,
...globals.browser,
},
parserOptions: {
project: "./tsconfig.eslint.json",
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"@typescript-eslint": tseslint.plugin,
vitest: eslintPluginVitest,
react: reactPlugin,
"react-hooks": reactHooksPlugin,
},
settings: {
react: {
version: "detect",
},
},
},
// JSON configuration
{
files: ["**/*.json"],
plugins: {
jsonc: eslintPluginJsonc,
},
languageOptions: {
parser: eslintPluginJsonc,
},
rules: {
...eslintPluginJsonc.configs["recommended-with-json"].rules,
},
},
// Package.json specific configuration
{
files: ["package.json"],
languageOptions: {
parser: eslintPluginJsonc,
},
plugins: {
"package-json": packageJsonPlugin,
},
rules: {
...packageJsonPlugin.configs.recommended.rules,
},
},
// Apply Prettier config at the end to override formatting rules
eslintConfigPrettier,
]);