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'
7
3
import iterateJsdoc from '../iterateJsdoc' ;
8
4
9
5
const zeroBasedLineIndexAdjust = - 1 ;
@@ -85,6 +81,13 @@ export default iterateJsdoc(({
85
81
context,
86
82
globalState,
87
83
} ) => {
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
+
88
91
if ( ! globalState . has ( 'checkExamples-matchingFileName' ) ) {
89
92
globalState . set ( 'checkExamples-matchingFileName' , new Map ( ) ) ;
90
93
}
@@ -172,16 +175,16 @@ export default iterateJsdoc(({
172
175
if ( matchingFileNameMap . has ( fileNameMapKey ) ) {
173
176
cliFile = matchingFileNameMap . get ( fileNameMapKey ) ;
174
177
} else {
175
- const cli = new CLIEngine ( cliConfig ) ;
178
+ const cli = new ESLint ( cliConfig ) ;
176
179
let config ;
177
180
if ( filename || checkEslintrc ) {
178
- config = cli . getConfigForFile ( file ) ;
181
+ config = cli . calculateConfigForFile ( file ) ;
179
182
}
180
183
181
184
// We need a new instance to ensure that the rules that may only
182
185
// be available to `file` (if it has its own `.eslintrc`),
183
186
// will be defined.
184
- cliFile = new CLIEngine ( {
187
+ cliFile = new ESLint ( {
185
188
allowInlineConfig,
186
189
baseConfig : {
187
190
...baseConfig ,
@@ -196,8 +199,7 @@ export default iterateJsdoc(({
196
199
matchingFileNameMap . set ( fileNameMapKey , cliFile ) ;
197
200
}
198
201
199
- const { results : [ { messages} ] } =
200
- cliFile . executeOnText ( src ) ;
202
+ const { results : [ { messages } ] } = cliFile . lintText ( src ) ;
201
203
202
204
if ( ! ( 'line' in tag ) ) {
203
205
tag . line = tag . source [ 0 ] . number ;
0 commit comments