diff --git a/package.json b/package.json index 0ed3ebe..8de7e6d 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,9 @@ "linting" ], "license": "Apache-2.0", + "dependencies": { + "@humanwhocodes/momoa": "^3.1.1" + }, "devDependencies": { "@eslint/core": "^0.1.0", "@types/eslint": "^8.56.10", @@ -77,9 +80,6 @@ "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, - "dependencies": { - "@humanwhocodes/momoa": "^3.0.6" - }, "peerDependencies": { "eslint": "^9.6.0" } diff --git a/src/languages/json-language.js b/src/languages/json-language.js index 1b87fec..5cb87bc 100644 --- a/src/languages/json-language.js +++ b/src/languages/json-language.js @@ -9,6 +9,7 @@ import { parse } from "@humanwhocodes/momoa"; import { JSONSourceCode } from "./json-source-code.js"; +import { visitorKeys } from "@humanwhocodes/momoa"; //----------------------------------------------------------------------------- // Types @@ -59,6 +60,12 @@ export class JSONLanguage { */ #mode = "json"; + /** + * The visitor keys. + * @type {Record} + */ + visitorKeys = Object.fromEntries([...visitorKeys]); + /** * Creates a new instance. * @param {Object} options The options to use for this instance. diff --git a/tests/languages/json-language.test.js b/tests/languages/json-language.test.js index ca02533..98d5bf1 100644 --- a/tests/languages/json-language.test.js +++ b/tests/languages/json-language.test.js @@ -15,6 +15,14 @@ import assert from "node:assert"; //----------------------------------------------------------------------------- describe("JSONLanguage", () => { + describe("visitorKeys", () => { + it("should have visitorKeys property", () => { + const language = new JSONLanguage({ mode: "json" }); + + assert.deepStrictEqual(language.visitorKeys.Document, ["body"]); + }); + }); + describe("parse()", () => { it("should not parse jsonc by default", () => { const language = new JSONLanguage({ mode: "json" });