Replace strip-json-comments dev dependency with jsonc-parser to handle trailing comments in JSONC test input (for mdn/content), update test repo snapshots.

This commit is contained in:
David Anson 2024-01-21 20:14:18 -08:00
parent 555079da6d
commit 1769f70845
7 changed files with 20 additions and 32 deletions

View file

@ -3,6 +3,7 @@
"use strict";
const { join } = require("node:path").posix;
const jsoncParser = require("jsonc-parser");
const jsYaml = require("js-yaml");
const markdownlint = require("../lib/markdownlint");
@ -17,9 +18,8 @@ const markdownlint = require("../lib/markdownlint");
async function lintTestRepo(t, globPatterns, configPath) {
t.plan(1);
const { globby } = await import("globby");
const { "default": stripJsonComments } = await import("strip-json-comments");
const jsoncParse = (json) => {
const config = JSON.parse(stripJsonComments(json));
const config = jsoncParser.parse(json, [], { "allowTrailingComma": true });
return config.config || config;
};
const yamlParse = (yaml) => jsYaml.load(yaml);