Skip to content

Commit 84759e1

Browse files
authored
fix: consistently use json5 (#376)
we already use `json5` to parse JSON - no need for `strip-json-comments` as JSON5 supports comments.
1 parent f50f3d9 commit 84759e1

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
"commander": "^14.0.1",
5656
"husky": "^9.1.7",
5757
"jest": "^30.2.0",
58+
"json5": "^2.2.3",
5859
"lerna": "^8.2.3",
5960
"lint-staged": "^16.2.4",
6061
"markdown-toc": "^1.2.0",
6162
"prettier": "^3.6.2",
62-
"strip-json-comments": "^5.0.3",
6363
"typescript": "^5.9.3"
6464
},
6565
"workspaces": [

packages/openapi-code-generator/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"js-yaml": "^4.1.0",
6868
"json5": "^2.2.3",
6969
"lodash": "^4.17.21",
70-
"strip-json-comments": "^5.0.3",
7170
"tslib": "^2.8.1",
7271
"typescript": "^5.9.3",
7372
"zod": "^3.25.74"

packages/openapi-code-generator/src/core/loaders/typescript-formatter-config.loader.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from "node:path"
2+
import json5 from "json5"
23
import type {IFsAdaptor} from "../file-system/fs-adaptor"
34
import {logger} from "../logger"
45

@@ -22,11 +23,9 @@ export async function loadTypescriptFormatterConfig(
2223
if (biomeConfigFile) {
2324
const rawConfig = await fsAdaptor.readFile(biomeConfigFile)
2425

25-
const stripJsonComments = (await import("strip-json-comments")).default
26-
2726
return {
2827
type: "biome",
29-
config: JSON.parse(stripJsonComments(rawConfig)),
28+
config: json5.parse(rawConfig),
3029
}
3130
}
3231

pnpm-lock.yaml

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate-ajv-validator.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Ajv2020 = require("ajv/dist/2020")
88
const standaloneCode = require("ajv/dist/standalone").default
99
const addFormats = require("ajv-formats")
1010
const {Biome, Distribution} = require("@biomejs/js-api")
11-
const stripJsonComments = require("strip-json-comments").default
11+
const json5 = require("json5")
1212

1313
const openapi30Path = path.join(
1414
__dirname,
@@ -47,10 +47,8 @@ const writeOutput = async (filepath, moduleCode) => {
4747
path.resolve(path.join(__dirname, "..")),
4848
)
4949

50-
const biomeConfig = JSON.parse(
51-
stripJsonComments(
52-
await fs.readFile(path.join(__dirname, "../biome.jsonc"), "utf-8"),
53-
),
50+
const biomeConfig = json5.parse(
51+
await fs.readFile(path.join(__dirname, "../biome.jsonc"), "utf-8"),
5452
)
5553
biome.applyConfiguration(projectKey, biomeConfig)
5654

0 commit comments

Comments
 (0)