1
1
import path from "path"
2
2
import assert from "assert"
3
- import { CLIEngine } from "eslint"
3
+ import { ESLint } from "eslint"
4
4
import plugin from "../../lib/index"
5
5
6
6
// -----------------------------------------------------------------------------
@@ -10,16 +10,26 @@ import plugin from "../../lib/index"
10
10
const TEST_CWD = path . join ( __dirname , "../fixtures/integrations/eslint-plugin" )
11
11
12
12
describe ( "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
+ }
19
29
20
- assert . strictEqual ( r . results . length , 1 )
30
+ assert . strictEqual ( results . length , 1 )
21
31
assert . deepStrictEqual (
22
- r . results [ 0 ] . messages . map ( ( m ) => m . ruleId ) ,
32
+ results [ 0 ] . messages . map ( ( m ) => m . ruleId ) ,
23
33
[
24
34
"regexp/no-dupe-characters-character-class" ,
25
35
"regexp/prefer-w" ,
0 commit comments