@@ -2,7 +2,10 @@ import type * as eslint from "eslint";
22import { getRuleTester } from "eslint-compat-utils/rule-tester" ;
33import * as jsonParser from "jsonc-eslint-parser" ;
44import jsonPlugin from "@eslint/json" ;
5+ import semver from "semver" ;
6+ import { getESLint } from "eslint-compat-utils/eslint" ;
57const RuleTester = getRuleTester ( ) ;
8+ const ESLint = getESLint ( ) ;
69
710export type ValidTestCase = eslint . RuleTester . ValidTestCase & {
811 ignoreMomoa ?: boolean ;
@@ -25,19 +28,20 @@ class JSONRuleTester {
2528 this . _testerOptions = options ;
2629 const { ignoreMomoa, ...rest } = options || { } ;
2730 this . testerForBase = new RuleTester ( rest ) ;
28- this . testerForMomoa = ignoreMomoa
29- ? null
30- : new RuleTester ( {
31- ...rest ,
32- plugins : {
33- json : jsonPlugin as any ,
34- } ,
35- language : "json/json5" ,
36- languageOptions : {
37- ...rest ?. languageOptions ,
38- parser : undefined ,
39- } ,
40- } ) ;
31+ this . testerForMomoa =
32+ ! ignoreMomoa && semver . satisfies ( ESLint . version , ">=9.6.0" )
33+ ? new RuleTester ( {
34+ ...rest ,
35+ plugins : {
36+ json : jsonPlugin as any ,
37+ } ,
38+ language : "json/json5" ,
39+ languageOptions : {
40+ ...rest ?. languageOptions ,
41+ parser : undefined ,
42+ } ,
43+ } )
44+ : null ;
4145 }
4246
4347 public run (
0 commit comments