1+ import { fixupPluginRules } from "@eslint/compat" ;
2+ import { FlatCompat } from "@eslint/eslintrc" ;
13import js from "@eslint/js" ;
24import globals from "globals" ;
5+ import reactPlugin from 'eslint-plugin-react' ;
36import reactHooks from "eslint-plugin-react-hooks" ;
47import reactRefresh from "eslint-plugin-react-refresh" ;
58import tseslint from "typescript-eslint" ;
69import prettier from "eslint-plugin-prettier/recommended" ;
710
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+
825export default tseslint . config (
9- { ignores : [ "dist" ] } ,
26+ { ignores : [ "node_modules" , " dist" , "build "] } ,
1027 {
1128 extends : [
1229 js . configs . recommended ,
1330 ...tseslint . configs . recommended ,
1431 prettier ,
32+ ...compat . extends ( "plugin:import/typescript" ) ,
33+ reactPlugin . configs . flat . recommended ,
1534 ] ,
1635 files : [ "**/*.{ts,tsx}" ] ,
1736 languageOptions : {
@@ -21,14 +40,55 @@ export default tseslint.config(
2140 plugins : {
2241 "react-hooks" : reactHooks ,
2342 "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+ } ,
2452 } ,
2553 rules : {
2654 ...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" ,
2787 "react-refresh/only-export-components" : [
2888 "warn" ,
2989 { allowConstantExport : true } ,
3090 ] ,
31- "prettier/prettier " : "error" ,
91+ "semi " : [ "error" , "always" ] ,
3292 } ,
3393 }
3494) ;
0 commit comments