From be81237f5d45225ddfd955f0fcdbaa901289270a Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 3 Jul 2024 15:02:48 -0400 Subject: [PATCH 1/2] feat: Add JSONLanguage#visitorKeys Release-As: 0.1.0 --- src/languages/json-language.js | 7 +++++++ tests/languages/json-language.test.js | 8 ++++++++ 2 files changed, 15 insertions(+) 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" }); From ed8387e2f22bc29c014908002824e02f64629d01 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 4 Jul 2024 11:39:25 -0400 Subject: [PATCH 2/2] Update package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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" }