11const { defineConfig } = require ( 'eslint/config' ) ;
2- const js = require ( '@eslint/js' ) ;
2+ const { includeIgnoreFile } = require ( '@eslint/compat' ) ;
3+ const { rules : prettierConfigRules } = require ( 'eslint-config-prettier' ) ;
4+ const airbnb = require ( 'eslint-config-airbnb-extended' ) ;
35const globals = require ( 'globals' ) ;
4- const importPlugin = require ( 'eslint-plugin-import' ) ;
6+ const jest = require ( 'eslint-plugin-jest' ) ;
7+ const js = require ( '@eslint/js' ) ;
58const jsxA11y = require ( 'eslint-plugin-jsx-a11y' ) ;
6- const react = require ( 'eslint-plugin-react' ) ;
7- const reactHooks = require ( 'eslint-plugin-react-hooks' ) ;
9+ const path = require ( 'node:path' ) ;
10+ const playwright = require ( 'eslint-plugin-playwright' ) ;
11+ const prettierPlugin = require ( 'eslint-plugin-prettier' ) ;
812const reactCompiler = require ( 'eslint-plugin-react-compiler' ) ;
913const unusedImports = require ( 'eslint-plugin-unused-imports' ) ;
10- const pluginJest = require ( 'eslint-plugin-jest' ) ;
11- const playwright = require ( 'eslint-plugin-playwright' ) ;
12- const airbnb = require ( 'eslint-config-airbnb-extended/legacy' ) ;
13- const prettierRecommended = require ( 'eslint-plugin-prettier/recommended' ) ;
14+
15+ const jsConfig = [
16+ {
17+ name : 'js/config' ,
18+ ...js . configs . recommended ,
19+ } ,
20+ airbnb . plugins . stylistic ,
21+ airbnb . plugins . importX ,
22+ ...airbnb . configs . base . recommended ,
23+ ] ;
24+
25+ const reactConfig = [
26+ reactCompiler . configs . recommended ,
27+ airbnb . plugins . react ,
28+ airbnb . plugins . reactHooks ,
29+ airbnb . plugins . reactA11y ,
30+ ...airbnb . configs . react . recommended ,
31+ ] ;
32+
33+ const typescriptConfig = [
34+ // TypeScript ESLint Plugin
35+ airbnb . plugins . typescriptEslint ,
36+ // Airbnb Base TypeScript Config
37+ ...airbnb . configs . base . typescript ,
38+ // Airbnb React TypeScript Config
39+ ...airbnb . configs . react . typescript ,
40+ ] ;
41+
42+ const prettierConfig = [
43+ {
44+ name : 'prettier/plugin/config' ,
45+ plugins : {
46+ prettier : prettierPlugin ,
47+ } ,
48+ } ,
49+ {
50+ name : 'prettier/config' ,
51+ rules : {
52+ ...prettierConfigRules ,
53+ 'prettier/prettier' : 'error' ,
54+ } ,
55+ } ,
56+ ] ;
57+
58+ const jestConfig = [
59+ {
60+ files : [ '{src|tests}/**/*.{test|spec}.ts' ] ,
61+ plugins : { jest } ,
62+ languageOptions : {
63+ globals : jest . environments . globals . globals ,
64+ } ,
65+ } ,
66+ ] ;
67+
68+ const playwrightConfig = [
69+ {
70+ ...playwright . configs [ 'flat/recommended' ] ,
71+ files : [ 'playwright/**/*.{test|spec}.ts' ] ,
72+ } ,
73+ ] ;
1474
1575// Helper to disable jsx-a11y rules
1676const jsxA11yOffRules = Object . keys ( jsxA11y . rules ) . reduce ( ( acc , rule ) => {
@@ -20,14 +80,13 @@ const jsxA11yOffRules = Object.keys(jsxA11y.rules).reduce((acc, rule) => {
2080
2181module . exports = ( { tsconfigRootDir } ) =>
2282 defineConfig (
23- js . configs . recommended ,
24- ...airbnb . configs . react . typescript ,
25- importPlugin . flatConfigs . recommended ,
26- react . configs . flat . recommended ,
27- reactHooks . configs . flat . recommended ,
28- reactCompiler . configs . recommended ,
29- prettierRecommended ,
30-
83+ includeIgnoreFile ( path . resolve ( '.' , '.gitignore' ) ) ,
84+ ...jsConfig ,
85+ ...reactConfig ,
86+ ...typescriptConfig ,
87+ ...prettierConfig ,
88+ ...jestConfig ,
89+ ...playwrightConfig ,
3190 {
3291 files : [ '**/*.{ts,tsx,cts,mts}' ] ,
3392 plugins : {
@@ -56,10 +115,12 @@ module.exports = ({ tsconfigRootDir }) =>
56115
57116 rules : {
58117 ...jsxA11yOffRules ,
118+ 'arrow-body-style' : 'off' ,
59119 'class-methods-use-this' : 'off' ,
60- '@typescript-eslint/class-methods-use-this' : 'off' ,
61120 curly : [ 2 , 'all' ] ,
62121 'linebreak-style' : 'off' ,
122+ 'no-promise-executor-return' : 'warn' ,
123+ 'no-await-in-loop' : 'warn' ,
63124 'no-console' : 'off' ,
64125 'no-continue' : 'off' ,
65126 'no-multi-assign' : 'warn' ,
@@ -96,6 +157,14 @@ module.exports = ({ tsconfigRootDir }) =>
96157 ] ,
97158 } ,
98159 ] ,
160+ 'prefer-arrow-callback' : 'warn' ,
161+ '@typescript-eslint/consistent-indexed-object-style' : 'off' ,
162+ '@typescript-eslint/consistent-type-definitions' : 'off' ,
163+ '@typescript-eslint/ban-ts-comment' : 'warn' ,
164+ '@typescript-eslint/class-methods-use-this' : 'off' ,
165+ '@typescript-eslint/no-unsafe-enum-comparison' : 'warn' ,
166+ '@typescript-eslint/no-empty-object-type' : 'warn' ,
167+ '@typescript-eslint/prefer-destructuring' : 'warn' ,
99168 '@typescript-eslint/no-shadow' : 'warn' ,
100169 '@typescript-eslint/no-use-before-define' : 'warn' ,
101170 '@typescript-eslint/no-explicit-any' : 'warn' ,
@@ -118,11 +187,11 @@ module.exports = ({ tsconfigRootDir }) =>
118187 ] ,
119188 'max-classes-per-file' : 'off' ,
120189 'no-param-reassign' : [ 'warn' , { props : true , ignorePropertyModificationsFor : [ 'state' ] } ] ,
121- 'import/no-extraneous-dependencies' : 'off' ,
122- 'import/no-webpack-loader-syntax' : 'off' ,
123- 'import/no-unresolved' : 'off' ,
124- 'import/prefer-default-export' : 'off' ,
125- 'import/order' : [
190+ 'import-x /no-extraneous-dependencies' : 'off' ,
191+ 'import-x /no-webpack-loader-syntax' : 'off' ,
192+ 'import-x /no-unresolved' : 'off' ,
193+ 'import-x /prefer-default-export' : 'off' ,
194+ 'import-x /order' : [
126195 'error' ,
127196 {
128197 groups : [ [ 'builtin' , 'external' ] , 'internal' , [ 'sibling' , 'parent' ] ] ,
@@ -152,11 +221,14 @@ module.exports = ({ tsconfigRootDir }) =>
152221 'unused-imports/no-unused-imports' : 'error' ,
153222 'unused-imports/no-unused-vars' : 'off' ,
154223 'prefer-destructuring' : [ 'warn' , { object : true , array : false } ] ,
224+ 'prefer-rest-params' : 'warn' ,
155225 'prefer-promise-reject-errors' : 'warn' ,
156226 'prefer-spread' : 'warn' ,
157- '@typescript-eslint/ban-ts-comment' : 'warn' ,
158227 // Not required with the new JSX transform
159228 'react/react-in-jsx-scope' : 'off' ,
229+ 'react/no-array-index-key' : 'warn' ,
230+ 'react/jsx-no-useless-fragment' : 'warn' ,
231+ 'react/jsx-pascal-case' : 'warn' ,
160232 'react/destructuring-assignment' : 'off' ,
161233 'react/jsx-curly-brace-presence' : 'warn' ,
162234 'react/jsx-props-no-spreading' : 'off' ,
@@ -192,17 +264,4 @@ module.exports = ({ tsconfigRootDir }) =>
192264 '@stylistic/comma-dangle' : 'off' ,
193265 } ,
194266 } ,
195-
196- {
197- files : [ '{src|tests}/**/*.{test|spec}.ts' ] ,
198- plugins : { jest : pluginJest } ,
199- languageOptions : {
200- globals : pluginJest . environments . globals . globals ,
201- } ,
202- } ,
203-
204- {
205- ...playwright . configs [ 'flat/recommended' ] ,
206- files : [ 'playwright/**/*.{test|spec}.ts' ] ,
207- } ,
208267 ) ;
0 commit comments