1- // Todo: When peerDeps bump to ESLint 7, see about replacing `CLIEngine`
2- // with non-deprecated `ESLint` class:
3- // https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated
4- import {
5- CLIEngine ,
6- } from 'eslint' ;
1+ import { ESLint } from 'eslint' ;
2+ import semver from 'semver'
73import iterateJsdoc from '../iterateJsdoc' ;
84
95const zeroBasedLineIndexAdjust = - 1 ;
@@ -85,6 +81,13 @@ export default iterateJsdoc(({
8581 context,
8682 globalState,
8783} ) => {
84+ if ( semver . gte ( ESLint . version , '8.0.0' ) ) {
85+ return context . report ( {
86+ loc : { start : { column : 1 , line : 1 } } ,
87+ message : `This rule cannot yet be supported for ESLint 8; you should either downgrade to ESLint 7 or disable this rule. The possibility for ESLint 8 support is being tracked at https://github.com/eslint/eslint/issues/14745` ,
88+ } ) ;
89+ }
90+
8891 if ( ! globalState . has ( 'checkExamples-matchingFileName' ) ) {
8992 globalState . set ( 'checkExamples-matchingFileName' , new Map ( ) ) ;
9093 }
@@ -172,16 +175,16 @@ export default iterateJsdoc(({
172175 if ( matchingFileNameMap . has ( fileNameMapKey ) ) {
173176 cliFile = matchingFileNameMap . get ( fileNameMapKey ) ;
174177 } else {
175- const cli = new CLIEngine ( cliConfig ) ;
178+ const cli = new ESLint ( cliConfig ) ;
176179 let config ;
177180 if ( filename || checkEslintrc ) {
178- config = cli . getConfigForFile ( file ) ;
181+ config = cli . calculateConfigForFile ( file ) ;
179182 }
180183
181184 // We need a new instance to ensure that the rules that may only
182185 // be available to `file` (if it has its own `.eslintrc`),
183186 // will be defined.
184- cliFile = new CLIEngine ( {
187+ cliFile = new ESLint ( {
185188 allowInlineConfig,
186189 baseConfig : {
187190 ...baseConfig ,
@@ -196,8 +199,7 @@ export default iterateJsdoc(({
196199 matchingFileNameMap . set ( fileNameMapKey , cliFile ) ;
197200 }
198201
199- const { results : [ { messages} ] } =
200- cliFile . executeOnText ( src ) ;
202+ const { results : [ { messages } ] } = cliFile . lintText ( src ) ;
201203
202204 if ( ! ( 'line' in tag ) ) {
203205 tag . line = tag . source [ 0 ] . number ;
0 commit comments