1
- import { fixupConfigRules , fixupPluginRules } from '@eslint/compat'
2
- import typescriptEslint from '@typescript-eslint/eslint-plugin'
3
- import react from 'eslint-plugin-react'
4
- import reactRefresh from 'eslint-plugin-react-refresh'
1
+ import eslint from '@eslint/js'
2
+ import eslintPluginReact from 'eslint-plugin-react'
3
+ import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
4
+ import eslintPluginReactRefresh from 'eslint-plugin-react-refresh'
5
+ import eslintPluginUnicorn from 'eslint-plugin-unicorn'
6
+ import tseslint from 'typescript-eslint'
5
7
import globals from 'globals'
6
- import tsParser from '@typescript-eslint/parser'
7
- import path from 'node:path'
8
- import { fileURLToPath } from 'node:url'
9
- import js from '@eslint/js'
10
- import { FlatCompat } from '@eslint/eslintrc'
11
8
12
- const __filename = fileURLToPath ( import . meta. url )
13
- const __dirname = path . dirname ( __filename )
14
- const compat = new FlatCompat ( {
15
- baseDirectory : __dirname ,
16
- recommendedConfig : js . configs . recommended ,
17
- allConfig : js . configs . all ,
18
- } )
19
-
20
- export default [
9
+ export default tseslint . config (
21
10
{
22
- ignores : [ '**/coverage' , '**/node_modules/' , ' **/dist '] ,
11
+ ignores : [ '**/dist/ **/* ' ] ,
23
12
} ,
24
- ...fixupConfigRules (
25
- compat . extends (
26
- 'eslint:recommended' ,
27
- 'plugin:@typescript-eslint/recommended' ,
28
- 'plugin:@typescript-eslint/recommended-type-checked' ,
29
- 'plugin:@typescript-eslint/stylistic-type-checked' ,
30
- 'plugin:react/recommended' ,
31
- 'plugin:react-hooks/recommended' ,
32
- 'plugin:unicorn/recommended' ,
33
- ) ,
34
- ) ,
35
13
{
36
- plugins : {
37
- '@typescript-eslint' : fixupPluginRules ( typescriptEslint ) ,
38
- react : fixupPluginRules ( react ) ,
39
- 'react-refresh' : reactRefresh ,
40
- } ,
41
-
42
14
languageOptions : {
43
- globals : {
44
- ...globals . browser ,
45
- } ,
46
-
47
- parser : tsParser ,
48
- ecmaVersion : 'latest' ,
49
- sourceType : 'module' ,
50
-
51
15
parserOptions : {
52
- project : './tsconfig.json' ,
16
+ project : [ './tsconfig.json' ] ,
17
+ tsconfigRootDir : import . meta. dirname ,
53
18
} ,
54
19
} ,
55
20
@@ -58,46 +23,63 @@ export default [
58
23
version : 'detect' ,
59
24
} ,
60
25
} ,
61
-
26
+ } ,
27
+ eslint . configs . recommended ,
28
+ ...tseslint . configs . recommended ,
29
+ ...tseslint . configs . stylisticTypeChecked ,
30
+ ...tseslint . configs . strictTypeChecked ,
31
+ eslintPluginReact . configs . flat . recommended ,
32
+ {
33
+ plugins : {
34
+ 'react-hooks' : eslintPluginReactHooks ,
35
+ } ,
36
+ rules : eslintPluginReactHooks . configs . recommended . rules ,
37
+ } ,
38
+ eslintPluginUnicorn . configs [ 'flat/recommended' ] ,
39
+ {
40
+ // in main config for TSX/JSX source files
41
+ plugins : {
42
+ 'react-refresh' : eslintPluginReactRefresh ,
43
+ } ,
44
+ rules : { } ,
45
+ } ,
46
+ {
62
47
rules : {
63
- 'unicorn/prevent-abbreviations' : 'off' ,
64
- 'unicorn/no-null' : 'off' ,
65
- 'unicorn/filename-case' : 'off' ,
48
+ 'no-empty' : 'off' ,
49
+ 'no-console' : [
50
+ 'warn' ,
51
+ {
52
+ allow : [ 'error' , 'warn' ] ,
53
+ } ,
54
+ ] ,
55
+ 'no-underscore-dangle' : 'off' ,
56
+ curly : 'error' ,
57
+ semi : [ 'error' , 'never' ] ,
58
+ 'spaced-comment' : [
59
+ 'error' ,
60
+ 'always' ,
61
+ {
62
+ markers : [ '/' ] ,
63
+ } ,
64
+ ] ,
65
+
66
+ '@typescript-eslint/no-non-null-assertion' : 'off' ,
67
+ '@typescript-eslint/ban-ts-comment' : 'off' ,
66
68
'unicorn/no-useless-undefined' : 'off' ,
67
69
'unicorn/catch-error-name' : 'off' ,
68
- 'unicorn/no-nested-ternary' : 'off' ,
69
- 'unicorn/better-regex' : 'off' ,
70
- 'react/prop-types' : 'off' ,
71
- 'react/react-in-jsx-scope' : 'off' ,
70
+ 'unicorn/filename-case' : 'off' ,
71
+ 'unicorn/prevent-abbreviations' : 'off' ,
72
72
'react-refresh/only-export-components' : 'warn' ,
73
- '@typescript-eslint/no-base-to-string' : 'off' ,
74
- '@typescript-eslint/no-unsafe-member-access' : 'off' ,
75
- '@typescript-eslint/no-unsafe-argument' : 'off' ,
76
- '@typescript-eslint/no-unsafe-assignment' : 'off' ,
77
- '@typescript-eslint/no-unsafe-call' : 'off' ,
78
- '@typescript-eslint/no-unsafe-return' : 'off' ,
79
- '@typescript-eslint/restrict-template-expressions' : 'off' ,
80
- '@typescript-eslint/ban-ts-comment' : 'off' ,
81
- '@typescript-eslint/no-empty-function' : 'off' ,
82
-
73
+ 'react/no-unescaped-entities' : 'off' ,
74
+ 'react/prop-types' : 'off' ,
83
75
'@typescript-eslint/no-unused-vars' : [
84
76
'warn' ,
85
77
{
86
78
argsIgnorePattern : '^_' ,
87
79
ignoreRestSiblings : true ,
80
+ caughtErrors : 'none' ,
88
81
} ,
89
82
] ,
90
- 'no-console' : [
91
- 'warn' ,
92
- {
93
- allow : [ 'error' , 'warn' ] ,
94
- } ,
95
- ] ,
96
- curly : 'error' ,
97
- 'no-extra-semi' : 'off' ,
98
- 'unicorn/no-negated-condition' : 'off' ,
99
- 'unicorn/no-array-callback-reference' : 'off' ,
100
- 'unicorn/prefer-spread' : 'off' ,
101
83
} ,
102
84
} ,
103
- ]
85
+ )
0 commit comments