@@ -32,18 +32,20 @@ const importRules = tseslint.config({
32
32
plugins : {
33
33
'unused-imports' : unusedImports ,
34
34
'simple-import-sort' : simpleImportSort ,
35
- ' import' : importPlugin ,
35
+ import : importPlugin ,
36
36
} ,
37
37
rules : {
38
+ ...importPlugin . flatConfigs ?. recommended . rules ,
39
+ ...importPlugin . flatConfigs ?. typescript . rules ,
38
40
'no-unused-vars' : 'off' ,
39
41
'unused-imports/no-unused-imports' : 'error' ,
40
42
'unused-imports/no-unused-vars' : [
41
43
'warn' ,
42
44
{
43
- ' vars' : 'all' ,
44
- ' varsIgnorePattern' : '^_' ,
45
- ' args' : 'after-used' ,
46
- ' argsIgnorePattern' : '^_' ,
45
+ vars : 'all' ,
46
+ varsIgnorePattern : '^_' ,
47
+ args : 'after-used' ,
48
+ argsIgnorePattern : '^_' ,
47
49
} ,
48
50
] ,
49
51
'simple-import-sort/imports' : 'error' ,
@@ -53,18 +55,48 @@ const importRules = tseslint.config({
53
55
'import/no-duplicates' : 'error' ,
54
56
'import/no-unresolved' : 'off' ,
55
57
'import/no-named-as-default-member' : 'off' ,
56
- }
57
- } )
58
+ } ,
59
+ } ) ;
58
60
59
- const e2eRules = tseslint . config ( {
60
- extends : [ importRules ] ,
61
- ...playwright . configs [ 'flat/recommended' ] ,
62
- files : [ 'e2e/**/*.spec.ts' ] ,
61
+ const commonRules = tseslint . config ( {
62
+ extends : [
63
+ js . configs . recommended ,
64
+ ...tseslint . configs . recommended ,
65
+ importRules ,
66
+ ] ,
67
+ plugins : {
68
+ headers : headers ,
69
+ } ,
63
70
rules : {
64
- ...playwright . configs [ 'flat/recommended' ] . rules ,
71
+ 'headers/header-format' : [
72
+ 'error' ,
73
+ {
74
+ source : 'file' ,
75
+ path : '.actions/ASFLicenseHeader.txt' ,
76
+ } ,
77
+ ] ,
78
+ quotes : [
79
+ 'error' ,
80
+ 'single' ,
81
+ {
82
+ avoidEscape : true ,
83
+ allowTemplateLiterals : false ,
84
+ } ,
85
+ ] ,
65
86
} ,
66
87
} ) ;
67
88
89
+ const e2eRules = tseslint . config (
90
+ {
91
+ extends : [ commonRules ] ,
92
+ files : [ 'e2e/**/*.ts' ] ,
93
+ } ,
94
+ {
95
+ files : [ 'e2e/**/*.spec.ts' ] ,
96
+ ...playwright . configs [ 'flat/recommended' ] ,
97
+ }
98
+ ) ;
99
+
68
100
const i18nRules = tseslint . config ( {
69
101
files : [ 'src/**/*.{ts,tsx,js}' ] ,
70
102
plugins : {
@@ -74,10 +106,7 @@ const i18nRules = tseslint.config({
74
106
rules : {
75
107
...i18next . configs [ 'flat/recommended' ] . rules ,
76
108
'i18n/no-unknown-key' : 'error' ,
77
- 'i18n/no-text-as-children' : [
78
- 'error' ,
79
- { ignorePattern : '^\\s?[/.]\\s?$' } ,
80
- ] ,
109
+ 'i18n/no-text-as-children' : [ 'error' , { ignorePattern : '^\\s?[/.]\\s?$' } ] ,
81
110
'i18n/no-text-as-attribute' : [ 'error' , { attributes : [ 'alt' , 'title' ] } ] ,
82
111
'i18n/interpolation-data' : [
83
112
'error' ,
@@ -95,104 +124,67 @@ const i18nRules = tseslint.config({
95
124
functionName : 't' ,
96
125
} ,
97
126
} ,
98
- } )
127
+ } ) ;
128
+
129
+ const srcRules = tseslint . config ( {
130
+ extends : [ commonRules ] ,
131
+ files : [ 'src/**/*.{ts,tsx}' , 'eslint.config.ts' ] ,
132
+ languageOptions : {
133
+ ecmaVersion : 2020 ,
134
+ globals : globals . browser ,
135
+ sourceType : 'module' ,
136
+ } ,
137
+ plugins : {
138
+ 'react-hooks' : reactHooks ,
139
+ 'react-refresh' : reactRefresh ,
140
+ react : react ,
141
+ } ,
142
+ settings : {
143
+ react : {
144
+ version : 'detect' ,
145
+ } ,
146
+ } ,
147
+ rules : {
148
+ ...react . configs . flat . recommended . rules ,
149
+ ...react . configs . flat [ 'jsx-runtime' ] . rules ,
150
+ ...reactHooks . configs . recommended . rules ,
151
+ 'no-console' : 'warn' ,
152
+ 'react-refresh/only-export-components' : [
153
+ 'warn' ,
154
+ { allowConstantExport : true } ,
155
+ ] ,
156
+ 'react/jsx-curly-brace-presence' : [
157
+ 'error' ,
158
+ {
159
+ props : 'never' ,
160
+ children : 'never' ,
161
+ } ,
162
+ ] ,
163
+ 'react/no-unescaped-entities' : [
164
+ 'error' ,
165
+ {
166
+ forbid : [ '>' , '}' ] ,
167
+ } ,
168
+ ] ,
169
+ 'react/no-children-prop' : [
170
+ 'error' ,
171
+ {
172
+ allowFunctions : true ,
173
+ } ,
174
+ ] ,
175
+ 'react/self-closing-comp' : [
176
+ 'error' ,
177
+ {
178
+ component : true ,
179
+ html : true ,
180
+ } ,
181
+ ] ,
182
+ } ,
183
+ } ) ;
99
184
100
185
export default tseslint . config (
101
186
{ ignores : [ 'dist' , 'src/routeTree.gen.ts' ] } ,
102
187
e2eRules ,
103
188
i18nRules ,
104
- {
105
- extends : [ js . configs . recommended , ...tseslint . configs . recommended , importRules ] ,
106
- files : [ 'src/**/*.{ts,tsx}' , 'eslint.config.ts' ] ,
107
- languageOptions : {
108
- ecmaVersion : 2020 ,
109
- globals : globals . browser ,
110
- sourceType : 'module' ,
111
- } ,
112
- plugins : {
113
- 'react-hooks' : reactHooks ,
114
- 'react-refresh' : reactRefresh ,
115
- react : react ,
116
- 'unused-imports' : unusedImports ,
117
- 'simple-import-sort' : simpleImportSort ,
118
- import : importPlugin ,
119
- headers : headers ,
120
- } ,
121
- settings : {
122
- react : {
123
- version : 'detect' ,
124
- } ,
125
- } ,
126
- rules : {
127
- ...react . configs . flat . recommended . rules ,
128
- ...react . configs . flat [ 'jsx-runtime' ] . rules ,
129
- ...reactHooks . configs . recommended . rules ,
130
- ...importPlugin . flatConfigs ?. recommended . rules ,
131
- ...importPlugin . flatConfigs ?. typescript . rules ,
132
- 'no-console' : 'warn' ,
133
- 'no-unused-vars' : 'off' ,
134
- 'unused-imports/no-unused-imports' : 'error' ,
135
- 'unused-imports/no-unused-vars' : [
136
- 'warn' ,
137
- {
138
- vars : 'all' ,
139
- varsIgnorePattern : '^_' ,
140
- args : 'after-used' ,
141
- argsIgnorePattern : '^_' ,
142
- } ,
143
- ] ,
144
- 'simple-import-sort/imports' : 'error' ,
145
- 'simple-import-sort/exports' : 'error' ,
146
- 'import/first' : 'error' ,
147
- 'import/newline-after-import' : 'error' ,
148
- 'import/no-duplicates' : 'error' ,
149
- 'import/no-unresolved' : 'off' ,
150
- 'import/no-named-as-default-member' : 'off' ,
151
- 'react-refresh/only-export-components' : [
152
- 'warn' ,
153
- { allowConstantExport : true } ,
154
- ] ,
155
- 'react/jsx-curly-brace-presence' : [
156
- 'error' ,
157
- {
158
- props : 'never' ,
159
- children : 'never' ,
160
- } ,
161
- ] ,
162
- 'react/no-unescaped-entities' : [
163
- 'error' ,
164
- {
165
- forbid : [ '>' , '}' ] ,
166
- } ,
167
- ] ,
168
- 'react/no-children-prop' : [
169
- 'error' ,
170
- {
171
- allowFunctions : true ,
172
- } ,
173
- ] ,
174
- 'react/self-closing-comp' : [
175
- 'error' ,
176
- {
177
- component : true ,
178
- html : true ,
179
- } ,
180
- ] ,
181
- 'headers/header-format' : [
182
- 'error' ,
183
- {
184
- source : 'file' ,
185
- path : '.actions/ASFLicenseHeader.txt' ,
186
- } ,
187
- ] ,
188
- 'quotes' : [
189
- 'error' ,
190
- 'single' ,
191
- {
192
- 'avoidEscape' : true ,
193
- 'allowTemplateLiterals' : false
194
- }
195
- ] ,
196
- } ,
197
- }
189
+ srcRules
198
190
) ;
0 commit comments