1- import path from 'node:path'
2- import { fileURLToPath } from 'node:url'
3-
41import js from '@eslint/js'
2+ import eslintReact from '@eslint-react/eslint-plugin'
53import eslintConfigPrettier from 'eslint-config-prettier'
6- import react from 'eslint-plugin-react '
4+ import perfectionist from 'eslint-plugin-perfectionist '
75import reactHooks from 'eslint-plugin-react-hooks'
86import simpleImportSort from 'eslint-plugin-simple-import-sort'
97import globals from 'globals'
108import tseslint from 'typescript-eslint'
119
12- const __filename = fileURLToPath ( import . meta. url )
13- const __dirname = path . dirname ( __filename )
14-
1510export default tseslint . config (
1611 {
1712 ignores : [ '**/compiled/' , '**/coverage/' , '**/dist/' , '**/node_modules/' ] ,
1813 } ,
1914 js . configs . recommended ,
2015 ...tseslint . configs . recommended ,
21- react . configs . flat . recommended ,
22- eslintConfigPrettier ,
16+ eslintReact . configs [ 'recommended-typescript' ] ,
2317 {
24- languageOptions : {
25- parserOptions : {
26- ecmaFeatures : {
27- jsx : true ,
28- } ,
29- project : path . join ( __dirname , 'tsconfig.eslint.json' ) ,
30- } ,
31- } ,
32-
3318 plugins : {
19+ perfectionist,
3420 'react-hooks' : reactHooks ,
3521 'simple-import-sort' : simpleImportSort ,
3622 } ,
3723
3824 rules : {
39- 'react-hooks/exhaustive-deps' : 'warn' ,
40- 'react-hooks/rules-of-hooks' : 'error' ,
41- 'react/jsx-sort-props' : 'error' ,
42- 'react/jsx-uses-react' : 'off' ,
43- 'react/react-in-jsx-scope' : 'off' ,
25+ ...reactHooks . configs [ 'recommended-latest' ] . rules ,
26+ // eslint-plugin-react-hooks (above) is the source of truth for hooks
27+ // rules, since it's backed by the React team's compiler. Disable the
28+ // overlapping rules from @eslint -react/eslint-plugin's recommended
29+ // config to avoid duplicate reports.
30+ '@eslint-react/exhaustive-deps' : 'off' ,
31+ '@eslint-react/rules-of-hooks' : 'off' ,
32+ 'perfectionist/sort-jsx-props' : 'error' ,
4433 'simple-import-sort/exports' : 'error' ,
4534 'simple-import-sort/imports' : 'error' ,
4635 'sort-imports' : 'off' ,
4736 'sort-keys' : 'error' ,
4837 } ,
49-
50- settings : {
51- react : {
52- version : 'detect' ,
53- } ,
54- } ,
5538 } ,
5639 {
5740 files : [ '**/*.js' ] ,
@@ -61,7 +44,6 @@ export default tseslint.config(
6144 } ,
6245 } ,
6346 rules : {
64- '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
6547 '@typescript-eslint/no-require-imports' : 'off' ,
6648 } ,
6749 } ,
@@ -73,17 +55,5 @@ export default tseslint.config(
7355 } ,
7456 } ,
7557 } ,
76- {
77- files : [ 'examples/**/*' ] ,
78- rules : {
79- '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
80- 'react/no-unknown-property' : [
81- 'error' ,
82- {
83- ignore : [ 'jsx' ] ,
84- } ,
85- ] ,
86- 'react/prop-types' : 'off' ,
87- } ,
88- } ,
58+ eslintConfigPrettier ,
8959)
0 commit comments