1
- import docusauruseslint from "@docusaurus/ eslint-plugin " ;
1
+ import { FlatCompat } from "@eslint/eslintrc " ;
2
2
import eslint from "@eslint/js" ;
3
3
import perfectionisteslint from "eslint-plugin-perfectionist" ;
4
4
import globals from "globals" ;
5
5
import tseslint from "typescript-eslint" ;
6
6
7
+ const compat = new FlatCompat ( {
8
+ baseDirectory : import . meta. dirname ,
9
+ } ) ;
10
+
7
11
export default tseslint . config (
8
12
// Use recommended eslint rules
9
13
eslint . configs . recommended ,
10
14
11
- // Use strict type-checked typescript-eslint rules
12
- tseslint . configs . strictTypeChecked ,
15
+ // Use recommended type-checked typescript-eslint rules
16
+ tseslint . configs . recommendedTypeChecked ,
13
17
14
18
// Use stylistic type-checked typescript-eslint rules
15
19
tseslint . configs . stylisticTypeChecked ,
16
20
21
+ // Use recommended Docusaurus rules
22
+ ...compat . extends ( "plugin:@docusaurus/recommended" ) ,
23
+
17
24
// Use recommended perfectionist rules
18
25
perfectionisteslint . configs [ "recommended-alphabetical" ] ,
19
26
@@ -24,6 +31,9 @@ export default tseslint.config(
24
31
// Support browser globals
25
32
...globals . browser ,
26
33
34
+ // Support ES2023 globals
35
+ ...globals . es2023 ,
36
+
27
37
// Support node globals
28
38
...globals . node ,
29
39
} ,
@@ -33,20 +43,63 @@ export default tseslint.config(
33
43
// Needed for type-aware linting
34
44
projectService : true ,
35
45
46
+ // Allow ES2022 syntax
47
+ sourceType : "module" ,
48
+
36
49
// Set the root directory of the project
37
50
// Needed for type-aware linting
38
51
tsconfigRootDir : import . meta. dirname ,
39
52
} ,
40
53
} ,
41
54
42
- plugins : {
43
- // Enable docusaurus plugin
44
- "@docusaurus" : docusauruseslint ,
45
- } ,
46
-
47
55
rules : {
48
- // Use recommended docusaurus rules
49
- ...docusauruseslint . configs . recommended . rules ,
56
+ // Use objects instead of records for empty types
57
+ "@typescript-eslint/consistent-indexed-object-style" : [
58
+ "error" ,
59
+ "index-signature" ,
60
+ ] ,
61
+
62
+ // Use types instead of interfaces
63
+ "@typescript-eslint/consistent-type-definitions" : [ "error" , "type" ] ,
64
+
65
+ // Allow promises in callbacks
66
+ "@typescript-eslint/no-misused-promises" : [
67
+ "error" ,
68
+ {
69
+ checksVoidReturn : false ,
70
+ } ,
71
+ ] ,
72
+
73
+ // Allow nullish coalescing operator for primitive types
74
+ "@typescript-eslint/prefer-nullish-coalescing" : [
75
+ "error" ,
76
+ {
77
+ ignorePrimitives : true ,
78
+ } ,
79
+ ] ,
80
+
81
+ // Allow async functions without await
82
+ "@typescript-eslint/require-await" : "off" ,
83
+
84
+ // Skip checking whether static methods are bound
85
+ "@typescript-eslint/unbound-method" : [
86
+ "error" ,
87
+ {
88
+ ignoreStatic : true ,
89
+ } ,
90
+ ] ,
91
+
92
+ // Allow anonymous default exports
93
+ "import/no-anonymous-default-export" : "off" ,
94
+
95
+ // Allow empty block statements
96
+ "no-empty" : "off" ,
97
+
98
+ // Allow empty destructuring patterns
99
+ "no-empty-pattern" : "off" ,
100
+
101
+ // Don't sort module members
102
+ "perfectionist/sort-modules" : "off" ,
50
103
} ,
51
104
} ,
52
105
) ;
0 commit comments