1
- import type { ESLint } from "eslint"
1
+ import type { ESLint , Linter , RuleTester } from "eslint"
2
2
3
- export default function compat ( eslint : any ) {
3
+ export default function compat ( eslint : any ) : {
4
+ ESLint : typeof ESLint
5
+ RuleTester : typeof RuleTester
6
+ Linter : typeof Linter
7
+ } {
4
8
return {
5
9
ESLint : eslint . ESLint || getESLintClassForV6 ( eslint ) ,
6
10
RuleTester : eslint . RuleTester ,
7
11
Linter : eslint . Linter ,
8
12
}
9
13
}
10
14
11
- function getESLintClassForV6 ( eslint : any ) : ESLint {
15
+ function getESLintClassForV6 ( eslint : any ) : typeof ESLint {
12
16
class ESLintForV6 {
13
17
public engine
14
18
19
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
15
20
static get version ( ) {
16
21
return eslint . CLIEngine . version
17
22
}
18
23
19
24
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
20
- constructor ( options : ESLint . Options ) {
25
+ constructor ( options : any ) {
21
26
const {
22
27
overrideConfig : {
23
28
plugins,
@@ -29,14 +34,14 @@ function getESLintClassForV6(eslint: any): ESLint {
29
34
plugins : [ ] ,
30
35
globals : { } ,
31
36
rules : { } ,
32
- } ,
37
+ } as any ,
33
38
overrideConfigFile,
34
39
fix,
35
40
reportUnusedDisableDirectives,
36
41
plugins : pluginsMap ,
37
42
...otherOptions
38
43
} = options || { }
39
- const newOptions : CLIEngine . Options = {
44
+ const newOptions = {
40
45
fix : Boolean ( fix ) ,
41
46
reportUnusedDisableDirectives : reportUnusedDisableDirectives
42
47
? reportUnusedDisableDirectives !== "off"
@@ -59,7 +64,7 @@ function getESLintClassForV6(eslint: any): ESLint {
59
64
}
60
65
return o
61
66
} ,
62
- { } satisfies NonNullable < CLIEngine . Options [ "rules" ] > ,
67
+ { } as Record < string , any > ,
63
68
)
64
69
: undefined ,
65
70
...overrideConfig ,
@@ -71,29 +76,33 @@ function getESLintClassForV6(eslint: any): ESLint {
71
76
}
72
77
}
73
78
79
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
74
80
async lintText (
75
81
...params : Parameters < ESLint [ "lintText" ] >
76
82
) : ReturnType < ESLint [ "lintText" ] > {
77
- const result = this . engine . executeOnText (
83
+ const result = await this . engine . executeOnText (
78
84
params [ 0 ] ,
79
85
params [ 1 ] ! . filePath ,
80
86
)
81
87
return result . results
82
88
}
83
89
90
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
84
91
async lintFiles (
85
92
...params : Parameters < ESLint [ "lintFiles" ] >
86
93
) : ReturnType < ESLint [ "lintFiles" ] > {
87
- const result = this . engine . executeOnFiles (
94
+ const result = await this . engine . executeOnFiles (
88
95
Array . isArray ( params [ 0 ] ) ? params [ 0 ] : [ params [ 0 ] ] ,
89
96
)
90
97
return result . results
91
98
}
92
99
100
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
93
101
static async outputFixes (
94
- ...params : Parameters < ESLint [ "outputFixes" ] >
95
- ) : ReturnType < ESLint [ "outputFixes" ] > {
96
- return eslint . CLIEngine . outputFixes ( {
102
+ ...params : Parameters < typeof ESLint . outputFixes >
103
+ ) : ReturnType < typeof ESLint . outputFixes > {
104
+ // eslint-disable-next-line no-return-await
105
+ return await eslint . CLIEngine . outputFixes ( {
97
106
results : params [ 0 ] ,
98
107
} )
99
108
}
0 commit comments