Skip to content

Commit 0c5f248

Browse files
committed
fix ci
1 parent 505e7e0 commit 0c5f248

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

tests/lib/test-lib/tester.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import type * as eslint from "eslint";
22
import { getRuleTester } from "eslint-compat-utils/rule-tester";
33
import * as jsonParser from "jsonc-eslint-parser";
44
import jsonPlugin from "@eslint/json";
5+
import semver from "semver";
6+
import { getESLint } from "eslint-compat-utils/eslint";
57
const RuleTester = getRuleTester();
8+
const ESLint = getESLint();
69

710
export 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

Comments
 (0)