1
- import js from "@eslint/js" ;
2
- import tseslint from "@typescript-eslint/eslint-plugin" ;
3
- import tsparser from "@typescript-eslint/parser" ;
4
- import react from "eslint-plugin-react" ;
5
- import reactHooks from "eslint-plugin-react-hooks" ;
6
- import importPlugin from "eslint-plugin-import" ;
7
- import type { Linter } from "eslint" ;
1
+ import js from '@eslint/js' ;
2
+ import tseslint from '@typescript-eslint/eslint-plugin' ;
3
+ import tsparser from '@typescript-eslint/parser' ;
4
+ // @ts -ignore - Plugin doesn't have proper ESLint 9 types yet
5
+ import importPlugin from 'eslint-plugin-import' ;
6
+ // @ts -ignore - Plugin doesn't have proper ESLint 9 types yet
7
+ import react from 'eslint-plugin-react' ;
8
+ // @ts -ignore - Plugin doesn't have proper ESLint 9 types yet
9
+ import reactHooks from 'eslint-plugin-react-hooks' ;
10
+ import prettierConfig from 'eslint-config-prettier' ;
8
11
9
12
export default [
13
+ // Base recommended configurations
10
14
js . configs . recommended ,
15
+
16
+ // TypeScript configuration for all TypeScript files
11
17
{
12
- files : [ " **/*.{js,jsx, ts,tsx}" ] ,
18
+ files : [ 'src/ **/*.{ts,tsx}' ] ,
13
19
languageOptions : {
14
20
parser : tsparser ,
15
21
parserOptions : {
16
- ecmaVersion : "latest" ,
17
- sourceType : "module" ,
22
+ ecmaVersion : 'latest' ,
23
+ sourceType : 'module' ,
24
+ project : './tsconfig.json' ,
18
25
ecmaFeatures : {
19
26
jsx : true ,
20
27
} ,
21
28
} ,
22
29
globals : {
23
- // Node.js globals
24
- process : "readonly" ,
25
- console : "readonly" ,
26
- // TypeScript/React globals
27
- React : "readonly" ,
28
- JSX : "readonly" ,
30
+ // Only keep React global for JSX without explicit React imports
31
+ React : 'writable' ,
29
32
} ,
30
33
} ,
31
34
plugins : {
32
- "@typescript-eslint" : tseslint as any ,
33
- react : react as any ,
34
- "react-hooks" : reactHooks as any ,
35
- import : importPlugin as any ,
35
+ '@typescript-eslint' : tseslint ,
36
36
} ,
37
37
rules : {
38
+ // Disable core ESLint rules that are covered by TypeScript
39
+ 'no-unused-vars' : 'off' ,
40
+ 'no-undef' : 'off' , // TypeScript handles this
41
+
42
+ // Apply TypeScript ESLint recommended rules
38
43
...tseslint . configs . recommended . rules ,
39
- ...react . configs . recommended . rules ,
40
- ...reactHooks . configs . recommended . rules ,
41
- "react/react-in-jsx-scope" : "off" ,
42
- "react/prop-types" : "off" ,
43
- "@typescript-eslint/no-unused-vars" : [ "error" , { argsIgnorePattern : "^_" } ] ,
44
- "@typescript-eslint/explicit-function-return-type" : "off" ,
45
- "@typescript-eslint/explicit-module-boundary-types" : "off" ,
46
- "@typescript-eslint/no-explicit-any" : "warn" ,
47
- // Allow regex escape characters
48
- "no-useless-escape" : "off" ,
44
+ // Override specific rules for our project needs
45
+ '@typescript-eslint/ban-ts-comment' : 'off' ,
46
+ '@typescript-eslint/no-explicit-any' : 'warn' ,
49
47
} ,
50
- settings : {
51
- react : {
52
- version : "detect" ,
48
+ } ,
49
+
50
+ // Node.js CLI configuration
51
+ {
52
+ files : [ 'src/cli/**/*.{ts,tsx}' ] ,
53
+ languageOptions : {
54
+ parser : tsparser ,
55
+ parserOptions : {
56
+ ecmaVersion : 'latest' ,
57
+ sourceType : 'module' ,
58
+ project : './tsconfig.json' ,
53
59
} ,
54
- "import/resolver" : {
55
- typescript : { } ,
60
+ globals : {
61
+ // Only the Node.js globals actually used in CLI files
62
+ process : 'readonly' ,
63
+ console : 'readonly' ,
56
64
} ,
57
65
} ,
66
+ plugins : {
67
+ '@typescript-eslint' : tseslint ,
68
+ } ,
69
+ rules : {
70
+ 'no-unused-vars' : 'off' ,
71
+ 'no-undef' : 'off' ,
72
+ ...tseslint . configs . recommended . rules ,
73
+ '@typescript-eslint/ban-ts-comment' : 'off' ,
74
+ '@typescript-eslint/no-explicit-any' : 'warn' ,
75
+ } ,
58
76
} ,
77
+
78
+ // React configuration
59
79
{
60
- ignores : [ "lib/**" , "node_modules/**" , "coverage/**" ] ,
80
+ files : [ 'src/**/*.{js,jsx,ts,tsx}' ] ,
81
+ languageOptions : {
82
+ parser : tsparser ,
83
+ parserOptions : {
84
+ ecmaVersion : 'latest' ,
85
+ sourceType : 'module' ,
86
+ project : './tsconfig.json' ,
87
+ ecmaFeatures : {
88
+ jsx : true ,
89
+ } ,
90
+ } ,
91
+ globals : {
92
+ React : 'writable' ,
93
+ } ,
94
+ } ,
95
+ plugins : {
96
+ react,
97
+ 'react-hooks' : reactHooks ,
98
+ import : importPlugin ,
99
+ } ,
100
+ settings : {
101
+ react : {
102
+ version : 'detect' ,
103
+ } ,
104
+ 'import/resolver' : {
105
+ typescript : {
106
+ project : './tsconfig.json' ,
107
+ } ,
108
+ node : {
109
+ extensions : [ '.js' , '.jsx' , '.ts' , '.tsx' ] ,
110
+ } ,
111
+ } ,
112
+ } ,
113
+ rules : {
114
+ // Apply React recommended rules
115
+ ...react . configs . recommended . rules ,
116
+ ...react . configs [ 'jsx-runtime' ] . rules ,
117
+
118
+ // Apply React Hooks recommended rules
119
+ ...reactHooks . configs . recommended . rules ,
120
+
121
+ // Apply Import recommended rules with custom order
122
+ 'import/no-unresolved' : 'off' , // TypeScript handles this
123
+ 'import/order' : [
124
+ 'error' ,
125
+ {
126
+ groups : [ 'builtin' , 'external' , 'internal' ] ,
127
+ pathGroups : [
128
+ {
129
+ pattern : 'react' ,
130
+ group : 'external' ,
131
+ position : 'before' ,
132
+ } ,
133
+ ] ,
134
+ pathGroupsExcludedImportTypes : [ 'react' ] ,
135
+ 'newlines-between' : 'always' ,
136
+ alphabetize : {
137
+ order : 'asc' ,
138
+ caseInsensitive : true ,
139
+ } ,
140
+ } ,
141
+ ] ,
142
+ } ,
61
143
} ,
62
- ] ;
144
+
145
+ // Prettier configuration (disables conflicting rules)
146
+ prettierConfig ,
147
+ ] ;
0 commit comments