@@ -8,7 +8,7 @@ let FlatESLint = eslint.ESLint
88let Linter = eslint . Linter
99let RuleTester = eslint . RuleTester
1010if ( semver . lt ( eslint . Linter . version , '9.0.0-0' ) ) {
11- ESLint = eslint . ESLint ? getESLintClassForV8 ( ) : getESLintClassForV6 ( )
11+ ESLint = getESLintClassForV8 ( )
1212 Linter = getLinterClassForV8 ( )
1313 RuleTester = getRuleTesterClassForV8 ( )
1414 try {
@@ -68,71 +68,6 @@ function getESLintClassForV8(BaseESLintClass = eslint.ESLint) {
6868 return newOptions
6969 }
7070}
71- /** @returns {typeof eslint.ESLint } */
72- function getESLintClassForV6 ( ) {
73- class ESLintForV6 {
74- static get version ( ) {
75- // @ts -expect-error
76- return eslint . CLIEngine . version
77- }
78-
79- /** @param {eslint.ESLint.Options } options */
80- constructor ( options ) {
81- const {
82- overrideConfig : { plugins, globals, rules, ...overrideConfig } = {
83- plugins : [ ] ,
84- globals : { } ,
85- rules : { }
86- } ,
87- fix,
88- reportUnusedDisableDirectives,
89- plugins : pluginsMap ,
90- ...otherOptions
91- } = options || { }
92-
93- const newOptions = {
94- fix : Boolean ( fix ) ,
95- reportUnusedDisableDirectives : reportUnusedDisableDirectives
96- ? reportUnusedDisableDirectives !== 'off'
97- : undefined ,
98- ...otherOptions ,
99-
100- globals : globals
101- ? Object . keys ( globals ) . filter ( ( n ) => globals [ n ] )
102- : undefined ,
103- plugins : plugins || [ ] ,
104- rules : rules
105- ? Object . fromEntries (
106- Object . entries ( rules ) . flatMap ( ( [ ruleId , opt ] ) =>
107- opt ? [ [ ruleId , opt ] ] : [ ]
108- )
109- )
110- : undefined ,
111- ...overrideConfig
112- }
113-
114- // @ts -expect-error
115- this . engine = new eslint . CLIEngine ( newOptions )
116-
117- for ( const [ name , plugin ] of Object . entries ( pluginsMap || { } ) ) {
118- this . engine . addPlugin ( name , plugin )
119- }
120- }
121-
122- /**
123- * @param {Parameters<eslint.ESLint['lintText']> } params
124- * @returns {ReturnType<eslint.ESLint['lintText']> }
125- */
126- async lintText ( ...params ) {
127- const result = this . engine . executeOnText ( params [ 0 ] , params [ 1 ] ?. filePath )
128- return result . results
129- }
130- }
131-
132- /** @type {typeof eslint.ESLint } */
133- const eslintClass = /** @type {any } */ ( ESLintForV6 )
134- return getESLintClassForV8 ( eslintClass )
135- }
13671
13772/** @returns {typeof eslint.Linter } */
13873function getLinterClassForV8 ( ) {
0 commit comments