11import path from "path"
22import assert from "assert"
3- import { CLIEngine } from "eslint"
3+ import { ESLint } from "eslint"
44import plugin from "../../lib/index"
55
66// -----------------------------------------------------------------------------
@@ -10,16 +10,26 @@ import plugin from "../../lib/index"
1010const TEST_CWD = path . join ( __dirname , "../fixtures/integrations/eslint-plugin" )
1111
1212describe ( "Integration with eslint-plugin-regexp" , ( ) => {
13- it ( "should lint without errors" , ( ) => {
14- const engine = new CLIEngine ( {
15- cwd : TEST_CWD ,
16- } )
17- engine . addPlugin ( "eslint-plugin-regexp" , plugin )
18- const r = engine . executeOnFiles ( [ "test.js" ] )
13+ it ( "should lint without errors" , async ( ) => {
14+ let results : ESLint . LintResult [ ]
15+ if ( ESLint ) {
16+ const eslint = new ESLint ( {
17+ cwd : TEST_CWD ,
18+ plugins : { "eslint-plugin-regexp" : plugin } ,
19+ } )
20+ results = await eslint . lintFiles ( [ "test.js" ] )
21+ } else {
22+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports -- ignore
23+ const engine = new ( require ( "eslint" ) . CLIEngine ) ( {
24+ cwd : TEST_CWD ,
25+ } )
26+ engine . addPlugin ( "eslint-plugin-regexp" , plugin )
27+ results = engine . executeOnFiles ( [ "test.js" ] ) . results
28+ }
1929
20- assert . strictEqual ( r . results . length , 1 )
30+ assert . strictEqual ( results . length , 1 )
2131 assert . deepStrictEqual (
22- r . results [ 0 ] . messages . map ( ( m ) => m . ruleId ) ,
32+ results [ 0 ] . messages . map ( ( m ) => m . ruleId ) ,
2333 [
2434 "regexp/no-dupe-characters-character-class" ,
2535 "regexp/prefer-w" ,
0 commit comments