11// @ts -check
2- import path from "path" ;
3- import { fileURLToPath } from "url" ;
4-
5- import { fixupPluginRules } from "@eslint/compat" ;
6- import { FlatCompat } from "@eslint/eslintrc" ;
72import eslintJs from "@eslint/js" ;
83import stylistic from "@stylistic/eslint-plugin" ;
9- import etc from "eslint-plugin-etc " ;
4+ import * as importPlugin from "eslint-plugin-import " ;
105import jsdoc from "eslint-plugin-jsdoc" ;
11- import reactJsxRuntime from "eslint-plugin-react/configs/jsx-runtime.js " ;
12- import reactRecommended from "eslint-plugin-react/configs/recommended.js " ;
6+ import perfectionist from "eslint-plugin-perfectionist " ;
7+ import reactPlugin from "eslint-plugin-react" ;
138import sonarjs from "eslint-plugin-sonarjs" ;
149import globals from "globals" ;
1510import eslintTs from "typescript-eslint" ;
1611
1712const project = "./tsconfig.json" ;
18- const filename = fileURLToPath ( import . meta. url ) ;
19- const dirname = path . dirname ( filename ) ;
20- const compat = new FlatCompat ( {
21- baseDirectory : dirname ,
22- recommendedConfig : eslintJs . configs . recommended ,
23- } ) ;
2413
2514/**
26- * @param {string } name the pugin name
27- * @param {string } alias the plugin alias
28- * @returns {import("eslint").ESLint.Plugin }
15+ * @param {object } config the plugin config
16+ * @returns {import("typescript-eslint").ConfigWithExtends }
2917 */
30- function legacyPlugin ( name , alias = name ) {
31- const plugin = compat . plugins ( name ) [ 0 ] ?. plugins ?. [ alias ] ;
32-
33- if ( ! plugin ) {
34- throw new Error ( `Unable to resolve plugin ${ name } and/or alias ${ alias } ` ) ;
35- }
36-
37- return fixupPluginRules ( plugin ) ;
18+ function fixConfigTypes ( config ) {
19+ return config ;
3820}
3921
4022export default eslintTs . config (
4123 eslintJs . configs . recommended ,
4224 ...eslintTs . configs . recommendedTypeChecked ,
43- ... compat . extends ( "plugin:import/ typescript" ) ,
44- reactRecommended ,
45- reactJsxRuntime ,
25+ fixConfigTypes ( importPlugin . flatConfigs ?. typescript ) ,
26+ fixConfigTypes ( reactPlugin . configs . flat ?. recommended ) ,
27+ fixConfigTypes ( reactPlugin . configs . flat ?. [ "jsx-runtime" ] ) ,
4628 sonarjs . configs . recommended ,
4729 stylistic . configs . customize ( {
4830 braceStyle : "1tbs" ,
@@ -63,7 +45,7 @@ export default eslintTs.config(
6345 globals : { ...globals . browser , ...globals . node } ,
6446 parserOptions : {
6547 ecmaFeatures : { jsx : true } ,
66- ecmaVersion : 2024 ,
48+ ecmaVersion : 2023 ,
6749 jsxPragma : null ,
6850 project,
6951 tsconfigRootDir : import . meta. dirname ,
@@ -74,13 +56,12 @@ export default eslintTs.config(
7456 reportUnusedDisableDirectives : "error" ,
7557 } ,
7658 plugins : {
77- deprecation : legacyPlugin ( "eslint-plugin-deprecation" , "deprecation" ) ,
78- etc : fixupPluginRules ( etc ) ,
79- "extra-rules" : legacyPlugin ( "eslint-plugin-extra-rules" , "extra-rules" ) ,
80- import : legacyPlugin ( "eslint-plugin-import" , "import" ) ,
59+ import : importPlugin ,
8160 jsdoc,
61+ perfectionist,
8262 } ,
8363 settings : {
64+ "import/ignore" : [ "react-native" ] , // https://github.com/facebook/react-native/issues/28549
8465 "import/resolver" : {
8566 typescript : {
8667 alwaysTryTypes : true ,
@@ -95,7 +76,6 @@ export default eslintTs.config(
9576 {
9677 rules : {
9778 "@stylistic/arrow-parens" : [ "error" , "as-needed" ] ,
98- "@stylistic/indent" : "off" ,
9979 "@stylistic/indent-binary-ops" : "off" ,
10080 "@stylistic/jsx-curly-brace-presence" : [ "error" , { children : "always" } ] ,
10181 "@stylistic/jsx-curly-newline" : "off" ,
@@ -117,6 +97,7 @@ export default eslintTs.config(
11797 "@stylistic/no-mixed-spaces-and-tabs" : "error" ,
11898 "@stylistic/no-multiple-empty-lines" : [ "error" , { max : 1 , maxBOF : 0 , maxEOF : 0 } ] ,
11999 "@stylistic/object-curly-spacing" : [ "error" , "always" ] ,
100+ "@stylistic/object-property-newline" : [ "error" , { allowAllPropertiesOnSameLine : true } ] ,
120101 "@stylistic/padded-blocks" : [ "error" , "never" , { allowSingleLineBlocks : false } ] ,
121102 "@stylistic/quote-props" : [ "error" , "as-needed" ] ,
122103 "@stylistic/quotes" : [ "error" , "double" , {
@@ -125,7 +106,6 @@ export default eslintTs.config(
125106 } ] ,
126107 "@stylistic/space-before-function-paren" : [ "error" , { anonymous : "never" , named : "never" } ] ,
127108 "@stylistic/switch-colon-spacing" : "error" ,
128- "@typescript-eslint/ban-types" : "error" ,
129109 "@typescript-eslint/consistent-type-assertions" : "error" ,
130110 "@typescript-eslint/consistent-type-exports" : "error" ,
131111 "@typescript-eslint/consistent-type-imports" : [ "error" , { fixStyle : "inline-type-imports" } ] ,
@@ -187,14 +167,11 @@ export default eslintTs.config(
187167 camelcase : "error" ,
188168 "constructor-super" : "error" ,
189169 curly : "error" ,
190- "deprecation/deprecation" : "error" ,
191170 eqeqeq : "error" ,
192- "etc/no-assign-mutated-array" : "error" ,
193- "etc/no-implicit-any-catch" : "error" ,
194- "etc/no-internal" : "error" ,
195- "etc/throw-error" : "error" ,
196- "extra-rules/no-commented-out-code" : "error" ,
197171 "func-style" : [ "error" , "declaration" , { allowArrowFunctions : true } ] ,
172+ "import/default" : "off" ,
173+ "import/named" : "off" ,
174+ "import/namespace" : "off" ,
198175 "import/newline-after-import" : "error" ,
199176 "import/no-absolute-path" : "error" ,
200177 "import/no-cycle" : [ "error" , {
@@ -204,7 +181,8 @@ export default eslintTs.config(
204181 } ] ,
205182 "import/no-duplicates" : [ "error" , { "prefer-inline" : true } ] ,
206183 "import/no-import-module-exports" : "error" ,
207- "import/no-namespace" : "error" ,
184+ "import/no-named-as-default-member" : "off" ,
185+ "import/no-namespace" : [ "error" , { ignore : [ "eslint-plugin-import" ] } ] ,
208186 "import/no-relative-packages" : "error" ,
209187 "import/no-unresolved" : "error" ,
210188 "import/no-useless-path-segments" : "error" ,
@@ -247,6 +225,11 @@ export default eslintTs.config(
247225 "no-var" : "error" ,
248226 "object-shorthand" : "error" ,
249227 "one-var" : [ "error" , "never" ] ,
228+ "perfectionist/sort-interfaces" : [ "error" , { ignoreCase : false , type : "natural" } ] ,
229+ "perfectionist/sort-intersection-types" : [ "error" , { ignoreCase : false , type : "natural" } ] ,
230+ "perfectionist/sort-object-types" : [ "error" , { ignoreCase : false , type : "natural" } ] ,
231+ "perfectionist/sort-objects" : [ "error" , { ignoreCase : false , type : "natural" } ] ,
232+ "perfectionist/sort-union-types" : [ "error" , { ignoreCase : false , type : "natural" } ] ,
250233 "prefer-const" : "error" ,
251234 radix : "error" ,
252235 "react/display-name" : "off" ,
@@ -256,10 +239,17 @@ export default eslintTs.config(
256239 "react/jsx-no-literals" : "error" ,
257240 "react/prop-types" : "off" ,
258241 "sonarjs/cognitive-complexity" : "off" ,
242+ "sonarjs/different-types-comparison" : "off" ,
243+ "sonarjs/function-return-type" : "off" ,
259244 "sonarjs/no-duplicate-string" : "off" ,
260- "sonarjs/no-inverted-boolean-check" : "error" ,
245+ "sonarjs/no-empty-function" : "off" ,
246+ "sonarjs/no-extend-native" : "off" ,
247+ "sonarjs/no-nested-functions" : "off" ,
248+ "sonarjs/no-selector-parameter" : "off" ,
249+ "sonarjs/no-unused-expressions" : "off" ,
250+ "sonarjs/public-static-readonly" : "off" ,
251+ "sonarjs/sonar-prefer-read-only-props" : "off" ,
261252 "sort-imports" : [ "error" , { ignoreDeclarationSort : true } ] ,
262- "sort-keys" : "error" ,
263253 } ,
264254 } ,
265255 {
@@ -273,11 +263,6 @@ export default eslintTs.config(
273263 rules : {
274264 ...eslintTs . configs . disableTypeChecked . rules ,
275265 "@typescript-eslint/explicit-function-return-type" : "off" ,
276- "deprecation/deprecation" : "off" ,
277- "etc/no-assign-mutated-array" : "off" ,
278- "etc/no-implicit-any-catch" : "off" ,
279- "etc/no-internal" : "off" ,
280- "etc/throw-error" : "off" ,
281266 } ,
282267 } ,
283268 {
@@ -290,8 +275,11 @@ export default eslintTs.config(
290275 files : [ "**/*.test.ts?(x)" ] ,
291276 rules : {
292277 "@typescript-eslint/no-non-null-assertion" : "off" ,
278+ "@typescript-eslint/prefer-promise-reject-errors" : "off" ,
293279 "@typescript-eslint/restrict-template-expressions" : "off" ,
294- "etc/throw-error" : "off" ,
280+ "sonarjs/assertions-in-tests" : "off" ,
281+ "sonarjs/no-empty-test-file" : "off" ,
282+ "sonarjs/no-nested-functions" : "off" ,
295283 } ,
296284 } ,
297285) ;
0 commit comments