Skip to content

Commit 86ab0ca

Browse files
authoredMar 20, 2025··
Add 'allowTrailingCommas' configuration to config-schema.json (#8461)
* Add 'allowTrailingCommas' configuration to config-schema.json * Add changeset
1 parent 257e7f9 commit 86ab0ca

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed
 

‎.changeset/plenty-bats-jog.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Add a 'allowTrailingCommas: true' option to improve IDE experience of 'wrangler.jsonc?'

‎packages/wrangler/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"clean": "rimraf wrangler-dist miniflare-dist emitted-types",
5959
"dev": "pnpm run clean && concurrently -c black,blue --kill-others-on-fail false \"pnpm run bundle --watch\" \"pnpm run check:type --watch --preserveWatchOutput\"",
6060
"emit-types": "tsc -p tsconfig.emit.json && node -r esbuild-register scripts/emit-types.ts",
61-
"generate-json-schema": "pnpm exec ts-json-schema-generator --no-type-check --path src/config/config.ts --type RawConfig --out config-schema.json",
61+
"generate-json-schema": "node -r esbuild-register scripts/generate-json-schema.ts",
6262
"prepublishOnly": "cross-env SOURCEMAPS=false pnpm exec turbo build -F wrangler",
6363
"start": "pnpm run bundle && cross-env NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
6464
"test": "dotenv -- pnpm run assert-git-version && dotenv -- vitest",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { writeFileSync } from "fs";
2+
import { join } from "path";
3+
import { createGenerator } from "ts-json-schema-generator";
4+
import type { Config, Schema } from "ts-json-schema-generator";
5+
6+
const config: Config = {
7+
path: join(__dirname, "../src/config/config.ts"),
8+
tsconfig: join(__dirname, "../tsconfig.json"),
9+
type: "RawConfig",
10+
skipTypeCheck: true,
11+
};
12+
13+
const applyFormattingRules = (schema: Schema) => {
14+
return { ...schema, allowTrailingCommas: true };
15+
};
16+
17+
const schema = applyFormattingRules(
18+
createGenerator(config).createSchema(config.type)
19+
);
20+
21+
writeFileSync(
22+
join(__dirname, "../config-schema.json"),
23+
JSON.stringify(schema, null, 2)
24+
);

0 commit comments

Comments
 (0)
Please sign in to comment.