import * as eslint from 'eslint' ; export namespace ESLint { export type LintResult = eslint . ESLint . LintResult ; } export const ESLint = eslint . ESLint || getESLintClassForV6 ( ) ; type ESLintCLIEngine = any ; function getESLintClassForV6 ( ) { const CLIEngine = ( eslint as any ) . CLIEngine ; class ESLintForV6 { private engine : ESLintCLIEngine ; static get version ( ) { return CLIEngine . version ; } constructor ( options ? ) { const { overrideConfig : { plugins , globals , rules , ... overrideConfig } = { plugins : [ ] , globals : { } , rules : { } } , fix , reportUnusedDisableDirectives , plugins : pluginsMap , ... otherOptions } = options || { } ; const newOptions = { fix : Boolean ( fix ) , reportUnusedDisableDirectives : reportUnusedDisableDirectives ? reportUnusedDisableDirectives !== 'off' : undefined , ... otherOptions , globals : globals ? Object . keys ( globals ) . filter ( n => globals [ n ] ) : undefined , plugins : plugins || [ ] , rules : rules ? Object . entries ( rules ) . reduce ( ( o , [ ruleId , opt ] ) => { if ( opt ) { o [ ruleId ] = opt ; } return o ; } , { } as NonNullable < ESLintCLIEngine [ 'Options' ] [ 'rules' ] > ) : undefined , ... overrideConfig } ; this . engine = new CLIEngine ( newOptions ) ; for ( const [ name , plugin ] of Object . entries ( pluginsMap || { } ) ) { this . engine . addPlugin ( name , plugin ) ; } } async lintText ( ... params ) { const result = this . engine . executeOnText ( params [ 0 ] , params [ 1 ] ?. filePath ) ; return result . results ; } async lintFiles ( ... params ) { const result = this . engine . executeOnFiles ( Array . isArray ( params [ 0 ] ) ? params [ 0 ] : [ params [ 0 ] ] ) ; return result . results ; } } const eslintClass = ESLintForV6 as never ; return eslintClass ; }