1
+ import { fixupPluginRules } from "@eslint/compat" ;
2
+ import { FlatCompat } from "@eslint/eslintrc" ;
1
3
import js from "@eslint/js" ;
2
4
import globals from "globals" ;
5
+ import reactPlugin from 'eslint-plugin-react' ;
3
6
import reactHooks from "eslint-plugin-react-hooks" ;
4
7
import reactRefresh from "eslint-plugin-react-refresh" ;
5
8
import tseslint from "typescript-eslint" ;
6
9
import prettier from "eslint-plugin-prettier/recommended" ;
7
10
11
+ const project = "./tsconfig.app.json" ;
12
+ // eslint flat structure backwards compatibility
13
+ const compat = new FlatCompat ( {
14
+ recommendedConfig : js . configs . recommended ,
15
+ } ) ;
16
+
17
+ function legacyPlugin ( name , alias = name ) {
18
+ const plugin = compat . plugins ( name ) [ 0 ] ?. plugins ?. [ alias ] ;
19
+ if ( ! plugin ) {
20
+ throw new Error ( `Unable to resolve plugin ${ name } and/or alias ${ alias } ` ) ;
21
+ }
22
+ return fixupPluginRules ( plugin ) ;
23
+ }
24
+
8
25
export default tseslint . config (
9
- { ignores : [ "dist" ] } ,
26
+ { ignores : [ "node_modules" , " dist" , "build "] } ,
10
27
{
11
28
extends : [
12
29
js . configs . recommended ,
13
30
...tseslint . configs . recommended ,
14
31
prettier ,
32
+ ...compat . extends ( "plugin:import/typescript" ) ,
33
+ reactPlugin . configs . flat . recommended ,
15
34
] ,
16
35
files : [ "**/*.{ts,tsx}" ] ,
17
36
languageOptions : {
@@ -21,14 +40,55 @@ export default tseslint.config(
21
40
plugins : {
22
41
"react-hooks" : reactHooks ,
23
42
"react-refresh" : reactRefresh ,
43
+ import : legacyPlugin ( "eslint-plugin-import" , "import" ) ,
44
+ } ,
45
+ settings : {
46
+ "import/resolver" : {
47
+ typescript : {
48
+ project,
49
+ alwaysTryTypes : true ,
50
+ } ,
51
+ } ,
24
52
} ,
25
53
rules : {
26
54
...reactHooks . configs . recommended . rules ,
55
+ "@typescript-eslint/no-empty-object-type" : "off" ,
56
+ "@typescript-eslint/no-unused-vars" : [ "error" , {
57
+ "argsIgnorePattern" : "^_" ,
58
+ "varsIgnorePattern" : "^_" ,
59
+ "caughtErrorsIgnorePattern" : "^_"
60
+ } ] ,
61
+ "import/order" : [ "error" , {
62
+ "groups" : [
63
+ "builtin" ,
64
+ "external" ,
65
+ "internal" ,
66
+ [ "parent" , "sibling" ] ,
67
+ "index" ,
68
+ "object" ,
69
+ "type" ,
70
+ "unknown"
71
+ ] ,
72
+ "pathGroups" : [
73
+ {
74
+ "pattern" : "@*" ,
75
+ "group" : "internal" ,
76
+ "position" : "after"
77
+ }
78
+ ] ,
79
+ "pathGroupsExcludedImportTypes" : [ "builtin" , "internal" ] ,
80
+ "newlines-between" : "always" ,
81
+ "alphabetize" : {
82
+ "order" : "asc" ,
83
+ "caseInsensitive" : true
84
+ }
85
+ } ] ,
86
+ "react/react-in-jsx-scope" : "off" ,
27
87
"react-refresh/only-export-components" : [
28
88
"warn" ,
29
89
{ allowConstantExport : true } ,
30
90
] ,
31
- "prettier/prettier " : "error" ,
91
+ "semi " : [ "error" , "always" ] ,
32
92
} ,
33
93
}
34
94
) ;
0 commit comments