1- import js from '@eslint/js' ;
1+ // eslint.config.js
2+ import eslint from '@eslint/js' ;
23import tseslint from 'typescript-eslint' ;
3- import react from 'eslint-plugin-react' ;
4- import reactHooks from 'eslint-plugin-react-hooks' ;
4+ import reactPlugin from 'eslint-plugin-react' ;
5+ import reactHooksPlugin from 'eslint-plugin-react-hooks' ;
56import prettier from 'eslint-plugin-prettier' ;
7+ import importPlugin from 'eslint-plugin-import' ;
68import globals from 'globals' ;
79
8- export default [
10+ export default tseslint . config (
911 {
1012 ignores : [ 'node_modules' , 'build' , 'dist' , 'eslint.config.js' , 'src/pubsub.js' ] ,
1113 } ,
12- js . configs . recommended , // Base JS rules
14+ eslint . configs . recommended ,
15+ ...tseslint . configs . recommended ,
1316 {
1417 languageOptions : {
1518 parser : tseslint . parser ,
@@ -22,26 +25,79 @@ export default [
2225 ...globals . node ,
2326 } ,
2427 } ,
28+
29+ // React plugin configuration
2530 plugins : {
26- '@typescript-eslint' : tseslint . plugin ,
27- react : react ,
28- 'react-hooks' : reactHooks ,
29- prettier : prettier ,
31+ react : reactPlugin ,
32+ 'react-hooks' : reactHooksPlugin ,
33+ import : importPlugin ,
34+ } ,
35+ rules : {
36+ // React rules
37+ 'react/jsx-uses-react' : 'error' ,
38+ 'react/jsx-uses-vars' : 'error' ,
39+ 'react/react-in-jsx-scope' : 'off' , // Not needed with React 17+
40+ 'react/prop-types' : 'off' , // TypeScript handles prop validation
41+ 'react/display-name' : 'warn' ,
42+ 'react-hooks/rules-of-hooks' : 'error' ,
43+ 'react-hooks/exhaustive-deps' : 'warn' ,
44+
45+ '@typescript-eslint/explici/t-function-return-type' : 'off' ,
46+ '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
47+ '@typescript-eslint/no-explicit-any' : 'warn' ,
48+ '@typescript-eslint/no-unused-vars' : [
49+ 'error' ,
50+ {
51+ argsIgnorePattern : '^_' ,
52+ varsIgnorePattern : '^_' ,
53+ } ,
54+ ] ,
55+
56+ // Import rules
57+ 'import/order' : [
58+ 'warn' ,
59+ {
60+ groups : [ 'builtin' , 'external' , 'internal' , 'parent' , 'sibling' , 'index' ] ,
61+ 'newlines-between' : 'always' ,
62+ alphabetize : { order : 'asc' , caseInsensitive : true } ,
63+ } ,
64+ ] ,
3065 } ,
66+ // Different settings for different file types
3167 settings : {
3268 react : {
3369 version : 'detect' ,
3470 } ,
3571 } ,
36- rules : {
37- 'prettier/prettier' : 'warn' ,
38- 'no-unused-vars' : 'off' , // Handled by TypeScript
39- '@typescript-eslint/no-unused-vars' : [ 'warn' , { argsIgnorePattern : '^_' } ] ,
40- 'react-hooks/rules-of-hooks' : 'error' ,
41- 'react-hooks/exhaustive-deps' : 'warn' ,
42- '@typescript-eslint/no-explicit-any' : 'warn' ,
43- '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
44- '@typescript-eslint/consistent-type-imports' : 'warn' ,
72+ } ,
73+ {
74+ // Apply to all JavaScript and TypeScript files
75+ files : [ '**/*.{js,jsx,ts,tsx}' ] ,
76+ languageOptions : {
77+ ecmaVersion : 2022 ,
78+ sourceType : 'module' ,
79+ parserOptions : {
80+ ecmaFeatures : {
81+ jsx : true ,
82+ } ,
83+ } ,
4584 } ,
4685 } ,
47- ] ;
86+ {
87+ // TypeScript-specific rules
88+ files : [ '**/*.{ts,tsx}' ] ,
89+ languageOptions : {
90+ parser : tseslint . parser ,
91+ parserOptions : {
92+ project : './tsconfig.json' ,
93+ } ,
94+ } ,
95+ } ,
96+ {
97+ // JavaScript-specific rules (for JSX files)
98+ files : [ '**/*.{js,jsx}' ] ,
99+ rules : {
100+ '@typescript-eslint/no-var-requires' : 'off' ,
101+ } ,
102+ }
103+ ) ;
0 commit comments