1
- import { FlatCompat } from "@eslint/eslintrc" ;
1
+ // @ts -check
2
2
import eslintJS from "@eslint/js" ;
3
- import typescriptParser from "@typescript-eslint/parser" ;
4
3
import eslintConfigPrettier from "eslint-config-prettier" ;
5
4
import globals from "globals" ;
6
- import { dirname } from "path" ;
7
- import { fileURLToPath } from "url" ;
5
+ import eslintTS from "typescript-eslint" ;
8
6
9
7
const allFiles = "**/*.?(c|m){js,ts}" ;
10
8
const jsFiles = "**/*.?(c|m)js" ;
11
9
const commonFiles = "**/*.c{js,ts}" ;
12
10
13
- const rootDir = dirname ( fileURLToPath ( import . meta. url ) ) ;
14
- const compat = new FlatCompat ( { baseDirectory : rootDir } ) ;
15
-
16
- export default [
11
+ export default eslintTS . config (
17
12
{ ignores : [ ".yarn/" , ".pnp.*" , "**/dist/" ] } ,
18
- { files : [ allFiles ] , ...eslintJS . configs . recommended } ,
19
- ...compat
20
- . extends (
21
- "plugin:@typescript-eslint/recommended-type-checked" ,
22
- "plugin:@typescript-eslint/stylistic-type-checked" ,
23
- )
24
- . map ( ( config ) => ( { files : [ allFiles ] , ...config } ) ) ,
25
- ...compat
26
- . extends ( "plugin:@typescript-eslint/disable-type-checked" )
27
- . map ( ( config ) => ( { files : [ jsFiles ] , ...config } ) ) ,
28
- { files : [ allFiles ] , ...eslintConfigPrettier } ,
29
13
{
30
14
files : [ allFiles ] ,
15
+ extends : [
16
+ eslintJS . configs . recommended ,
17
+ ...eslintTS . configs . recommendedTypeChecked ,
18
+ ...eslintTS . configs . stylisticTypeChecked ,
19
+ eslintConfigPrettier ,
20
+ ] ,
31
21
languageOptions : {
32
22
ecmaVersion : "latest" ,
33
23
sourceType : "module" ,
34
24
globals : globals . nodeBuiltin ,
35
- // Options specific to @typescript -eslint/parser
36
- parser : typescriptParser ,
25
+ parser : eslintTS . parser ,
37
26
parserOptions : {
38
27
allowAutomaticSingleRunInference : true ,
39
28
ecmaVersion : "latest" ,
@@ -44,6 +33,10 @@ export default [
44
33
reportUnusedDisableDirectives : true ,
45
34
} ,
46
35
} ,
36
+ {
37
+ files : [ jsFiles ] ,
38
+ extends : [ eslintTS . configs . disableTypeChecked ] ,
39
+ } ,
47
40
{
48
41
files : [ commonFiles ] ,
49
42
languageOptions : {
@@ -58,4 +51,4 @@ export default [
58
51
"@typescript-eslint/require-await" : "off" ,
59
52
} ,
60
53
} ,
61
- ] ;
54
+ ) ;
0 commit comments