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+
7+ export default [
8+ js . configs . recommended ,
9+ // JavaScript/JSX files
10+ {
11+ files : [ '**/*.{js,jsx}' ] ,
12+ plugins : {
13+ react,
14+ 'react-hooks' : reactHooks ,
15+ } ,
16+ languageOptions : {
17+ ecmaVersion : 'latest' ,
18+ sourceType : 'module' ,
19+ parserOptions : {
20+ ecmaFeatures : {
21+ jsx : true ,
22+ } ,
23+ } ,
24+ globals : {
25+ console : 'readonly' ,
26+ process : 'readonly' ,
27+ Buffer : 'readonly' ,
28+ __dirname : 'readonly' ,
29+ __filename : 'readonly' ,
30+ global : 'readonly' ,
31+ module : 'readonly' ,
32+ require : 'readonly' ,
33+ exports : 'readonly' ,
34+ document : 'readonly' ,
35+ window : 'readonly' ,
36+ fetch : 'readonly' ,
37+ setInterval : 'readonly' ,
38+ clearInterval : 'readonly' ,
39+ setTimeout : 'readonly' ,
40+ clearTimeout : 'readonly' ,
41+ confirm : 'readonly' ,
42+ NodeJS : 'readonly' ,
43+ preact : 'readonly' ,
44+ } ,
45+ } ,
46+ settings : {
47+ react : {
48+ pragma : 'h' ,
49+ fragment : 'Fragment' ,
50+ version : '16.0' , // Preact compatibility
51+ } ,
52+ } ,
53+ rules : {
54+ // Core rules
55+ 'no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
56+ 'no-console' : 'warn' ,
57+ 'prefer-const' : 'error' ,
58+
59+ // React/Preact specific rules
60+ 'react/jsx-uses-react' : 'error' ,
61+ 'react/jsx-uses-vars' : 'error' ,
62+ 'react/jsx-no-undef' : 'error' ,
63+ 'react/jsx-no-duplicate-props' : 'error' ,
64+ 'react/no-unknown-property' : [ 'error' , { ignore : [ 'class' ] } ] , // Allow 'class' for Preact
65+ 'react/self-closing-comp' : 'error' ,
66+
67+ // React Hooks rules
68+ 'react-hooks/rules-of-hooks' : 'error' ,
69+ 'react-hooks/exhaustive-deps' : 'warn' ,
70+ } ,
71+ } ,
72+ // TypeScript files
73+ {
74+ files : [ '**/*.{ts,tsx}' ] ,
75+ plugins : {
76+ '@typescript-eslint' : tseslint ,
77+ react,
78+ 'react-hooks' : reactHooks ,
79+ } ,
80+ languageOptions : {
81+ parser : tsparser ,
82+ ecmaVersion : 'latest' ,
83+ sourceType : 'module' ,
84+ parserOptions : {
85+ ecmaFeatures : {
86+ jsx : true ,
87+ } ,
88+ project : './tsconfig.json' ,
89+ } ,
90+ globals : {
91+ console : 'readonly' ,
92+ process : 'readonly' ,
93+ Buffer : 'readonly' ,
94+ __dirname : 'readonly' ,
95+ __filename : 'readonly' ,
96+ global : 'readonly' ,
97+ module : 'readonly' ,
98+ require : 'readonly' ,
99+ exports : 'readonly' ,
100+ document : 'readonly' ,
101+ window : 'readonly' ,
102+ fetch : 'readonly' ,
103+ setInterval : 'readonly' ,
104+ clearInterval : 'readonly' ,
105+ setTimeout : 'readonly' ,
106+ clearTimeout : 'readonly' ,
107+ confirm : 'readonly' ,
108+ NodeJS : 'readonly' ,
109+ preact : 'readonly' ,
110+ } ,
111+ } ,
112+ settings : {
113+ react : {
114+ pragma : 'h' ,
115+ fragment : 'Fragment' ,
116+ version : '16.0' , // Preact compatibility
117+ } ,
118+ } ,
119+ rules : {
120+ // Disable base rules that are covered by TypeScript equivalents
121+ 'no-unused-vars' : 'off' ,
122+ '@typescript-eslint/no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
123+
124+ // Core rules
125+ 'no-console' : 'warn' ,
126+ 'prefer-const' : 'error' ,
127+
128+ // TypeScript specific rules
129+ '@typescript-eslint/no-explicit-any' : 'warn' ,
130+ '@typescript-eslint/explicit-function-return-type' : 'off' ,
131+ '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
132+
133+ // React/Preact specific rules
134+ 'react/jsx-uses-react' : 'error' ,
135+ 'react/jsx-uses-vars' : 'error' ,
136+ 'react/jsx-no-undef' : 'error' ,
137+ 'react/jsx-no-duplicate-props' : 'error' ,
138+ 'react/no-unknown-property' : [ 'error' , { ignore : [ 'class' , 'stroke-linecap' , 'stroke-linejoin' , 'stroke-width' ] } ] , // Allow Preact and SVG attributes
139+ 'react/self-closing-comp' : 'error' ,
140+
141+ // React Hooks rules
142+ 'react-hooks/rules-of-hooks' : 'error' ,
143+ 'react-hooks/exhaustive-deps' : 'warn' ,
144+ } ,
145+ } ,
146+ ] ;
0 commit comments