1- import type { ESLint } from "eslint"
1+ import type { ESLint , Linter , RuleTester } from "eslint"
22
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+ } {
48 return {
59 ESLint : eslint . ESLint || getESLintClassForV6 ( eslint ) ,
610 RuleTester : eslint . RuleTester ,
711 Linter : eslint . Linter ,
812 }
913}
1014
11- function getESLintClassForV6 ( eslint : any ) : ESLint {
15+ function getESLintClassForV6 ( eslint : any ) : typeof ESLint {
1216 class ESLintForV6 {
1317 public engine
1418
19+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
1520 static get version ( ) {
1621 return eslint . CLIEngine . version
1722 }
1823
1924 // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
20- constructor ( options : ESLint . Options ) {
25+ constructor ( options : any ) {
2126 const {
2227 overrideConfig : {
2328 plugins,
@@ -29,14 +34,14 @@ function getESLintClassForV6(eslint: any): ESLint {
2934 plugins : [ ] ,
3035 globals : { } ,
3136 rules : { } ,
32- } ,
37+ } as any ,
3338 overrideConfigFile,
3439 fix,
3540 reportUnusedDisableDirectives,
3641 plugins : pluginsMap ,
3742 ...otherOptions
3843 } = options || { }
39- const newOptions : CLIEngine . Options = {
44+ const newOptions = {
4045 fix : Boolean ( fix ) ,
4146 reportUnusedDisableDirectives : reportUnusedDisableDirectives
4247 ? reportUnusedDisableDirectives !== "off"
@@ -59,7 +64,7 @@ function getESLintClassForV6(eslint: any): ESLint {
5964 }
6065 return o
6166 } ,
62- { } satisfies NonNullable < CLIEngine . Options [ "rules" ] > ,
67+ { } as Record < string , any > ,
6368 )
6469 : undefined ,
6570 ...overrideConfig ,
@@ -71,29 +76,33 @@ function getESLintClassForV6(eslint: any): ESLint {
7176 }
7277 }
7378
79+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
7480 async lintText (
7581 ...params : Parameters < ESLint [ "lintText" ] >
7682 ) : ReturnType < ESLint [ "lintText" ] > {
77- const result = this . engine . executeOnText (
83+ const result = await this . engine . executeOnText (
7884 params [ 0 ] ,
7985 params [ 1 ] ! . filePath ,
8086 )
8187 return result . results
8288 }
8389
90+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
8491 async lintFiles (
8592 ...params : Parameters < ESLint [ "lintFiles" ] >
8693 ) : ReturnType < ESLint [ "lintFiles" ] > {
87- const result = this . engine . executeOnFiles (
94+ const result = await this . engine . executeOnFiles (
8895 Array . isArray ( params [ 0 ] ) ? params [ 0 ] : [ params [ 0 ] ] ,
8996 )
9097 return result . results
9198 }
9299
100+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
93101 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 ( {
97106 results : params [ 0 ] ,
98107 } )
99108 }
0 commit comments