1
+ import { fixupConfigRules , fixupPluginRules } from "@eslint/compat" ;
2
+ import typescriptEslint from "@typescript-eslint/eslint-plugin" ;
3
+ import prettier from "eslint-plugin-prettier" ;
4
+ import _import from "eslint-plugin-import" ;
5
+ 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
+
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 [ {
21
+ ignores : [ "**/.eslintrc.js" , "**/react-app-env.d.ts" ] ,
22
+ } , ...fixupConfigRules ( compat . extends (
23
+ "eslint:recommended" ,
24
+ "plugin:@typescript-eslint/recommended" ,
25
+ "plugin:import/errors" ,
26
+ "plugin:import/warnings" ,
27
+ "plugin:import/typescript" ,
28
+ "plugin:prettier/recommended" ,
29
+ ) ) , {
30
+ plugins : {
31
+ "@typescript-eslint" : fixupPluginRules ( typescriptEslint ) ,
32
+ prettier : fixupPluginRules ( prettier ) ,
33
+ import : fixupPluginRules ( _import ) ,
34
+ } ,
35
+
36
+ languageOptions : {
37
+ globals : {
38
+ ...globals . browser ,
39
+ } ,
40
+
41
+ parser : tsParser ,
42
+ ecmaVersion : 12 ,
43
+ sourceType : "module" ,
44
+
45
+ parserOptions : {
46
+ ecmaFeatures : {
47
+ jsx : true ,
48
+ } ,
49
+ } ,
50
+ } ,
51
+
52
+ settings : {
53
+ "import/resolver" : {
54
+ node : {
55
+ extensions : [ ".js" , ".jsx" , ".ts" , ".tsx" ] ,
56
+ moduleDirectory : [ "node_modules" , "." ] ,
57
+ } ,
58
+ } ,
59
+ } ,
60
+
61
+ rules : {
62
+ "no-param-reassign" : [ "error" ] ,
63
+
64
+ "prettier/prettier" : [ "error" , {
65
+ endOfLine : "auto" ,
66
+ } ] ,
67
+
68
+ "linebreak-style" : 0 ,
69
+
70
+ "arrow-body-style" : [ "error" , "as-needed" , {
71
+ requireReturnForObjectLiteral : false ,
72
+ } ] ,
73
+
74
+ curly : [ "error" , "all" ] ,
75
+ "no-implicit-coercion" : [ "error" ] ,
76
+ "spaced-comment" : [ "error" , "always" ] ,
77
+ eqeqeq : [ "error" , "always" ] ,
78
+ "prefer-template" : "error" ,
79
+ "no-useless-concat" : "error" ,
80
+
81
+ "prefer-destructuring" : [ "error" , {
82
+ VariableDeclarator : {
83
+ array : false ,
84
+ object : true ,
85
+ } ,
86
+
87
+ AssignmentExpression : {
88
+ array : false ,
89
+ object : true ,
90
+ } ,
91
+ } , {
92
+ enforceForRenamedProperties : false ,
93
+ } ] ,
94
+
95
+ "import/extensions" : [ "error" , "ignorePackages" , {
96
+ ts : "never" ,
97
+ tsx : "never" ,
98
+ } ] ,
99
+
100
+ "import/no-extraneous-dependencies" : [ "error" , {
101
+ devDependencies : true ,
102
+ } ] ,
103
+
104
+ "import/order" : [ "error" , {
105
+ "newlines-between" : "always" ,
106
+ groups : [ "builtin" , "external" , "parent" , "sibling" , "index" ] ,
107
+
108
+ pathGroups : [ {
109
+ pattern : "src/**" ,
110
+ group : "parent" ,
111
+ position : "after" ,
112
+ } ] ,
113
+ } ] ,
114
+
115
+ "import/newline-after-import" : "error" ,
116
+ "@typescript-eslint/no-explicit-any" : "error" ,
117
+ "@typescript-eslint/explicit-function-return-type" : "off" ,
118
+ "@typescript-eslint/explicit-module-boundary-types" : "off" ,
119
+ "@typescript-eslint/no-empty-object-type" : [ "error" ] ,
120
+ "@typescript-eslint/no-unsafe-function-type" : [ "error" ] ,
121
+ "@typescript-eslint/no-wrapper-object-types" : [ "error" ] ,
122
+ "@typescript-eslint/no-shadow" : [ "error" ] ,
123
+
124
+ "@typescript-eslint/naming-convention" : [ "error" , {
125
+ selector : "default" ,
126
+ format : [ "camelCase" ] ,
127
+ } , {
128
+ selector : [ "memberLike" ] ,
129
+ modifiers : [ "private" ] ,
130
+ format : [ "camelCase" ] ,
131
+ leadingUnderscore : "allow" ,
132
+ } , {
133
+ selector : [ "enumMember" , "variable" ] ,
134
+ format : [ "camelCase" , "PascalCase" , "UPPER_CASE" ] ,
135
+ } , {
136
+ selector : "parameter" ,
137
+ format : [ "camelCase" ] ,
138
+ leadingUnderscore : "allow" ,
139
+ modifiers : [ "unused" ] ,
140
+ } , {
141
+ selector : "objectLiteralProperty" ,
142
+
143
+ filter : {
144
+ regex : "^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$" ,
145
+ match : true ,
146
+ } ,
147
+
148
+ format : null ,
149
+ } , {
150
+ selector : "typeLike" ,
151
+ format : [ "PascalCase" ] ,
152
+ } , {
153
+ selector : "typeProperty" ,
154
+ format : [ "snake_case" , "camelCase" ] ,
155
+ } ] ,
156
+ } ,
157
+ } ] ;
0 commit comments