Skip to content

Commit

Permalink
feat: Add JSONLanguage#visitorKeys
Browse files Browse the repository at this point in the history
Release-As: 0.1.0
  • Loading branch information
nzakas committed Jul 3, 2024
1 parent 4fcd8e0 commit be81237
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/languages/json-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { parse } from "@humanwhocodes/momoa";
import { JSONSourceCode } from "./json-source-code.js";
import { visitorKeys } from "@humanwhocodes/momoa";

//-----------------------------------------------------------------------------
// Types
Expand Down Expand Up @@ -59,6 +60,12 @@ export class JSONLanguage {
*/
#mode = "json";

/**
* The visitor keys.
* @type {Record<string, string[]>}
*/
visitorKeys = Object.fromEntries([...visitorKeys]);

/**
* Creates a new instance.
* @param {Object} options The options to use for this instance.
Expand Down
8 changes: 8 additions & 0 deletions tests/languages/json-language.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand Down

0 comments on commit be81237

Please sign in to comment.