#54107: docs: use json5 for bare object literal code blocks
Requested by David Sanders · Slack thread
Description of Change
Before: Six code blocks in the API docs contain nothing but a bare object literal (an example return value or options object) and are tagged ```js, each preceded by an <!-- eslint-skip --> comment. Four more blocks in the menus tutorial contain nothing but a bare array literal (menu templates, one of them inside a [!TIP] blockquote) and are also tagged ```js.
After: All ten blocks are tagged ```json5 and the <!-- eslint-skip --> comments are removed.
Why: the blocks are bare object and array literals, which are valid JSON5, and tagging them js doesn't play nicely with @electron/lint-roller. As JavaScript, { key: value, ... } on its own is a block statement rather than an object, so standard reports Parsing error: Unexpected token : on four of the six object blocks (the other two only parse because filters: is read as a label). They lint today only because lint-roller's lint-roller-markdown-standard and lint-roller-markdown-ts-check special-case them with a regex (wrapOrphanObjectInParens, inherited from standard-markdown) that wraps orphan {...} and [...] blocks in parentheses before linting, and disable no-labels/no-lone-blocks/no-unused-expressions to let that pass. Nothing in the current tooling honors <!-- eslint-skip -->, so those comments were dead. A companion website PR adds json5 to the site's Prism additional languages so the blocks keep highlighting.
How: fence tag changed from js to json5 and the preceding <!-- eslint-skip --> line dropped for the object literal blocks in docs/api/app.md (getGPUInfo basic response), docs/api/dialog.md (two filters examples), docs/api/structures/printer-info.md, docs/api/structures/trace-config.md, and docs/api/web-frame.md (getResourceUsage result); fence tag changed from js to json5 for the four menu template array blocks in docs/tutorial/menus.md (the three ordering examples and the adjacent-radio example in the [!TIP] blockquote). Each block was verified to parse with JSON5.parse. lint:js-in-markdown, lint:markdown, lint:ts-check-js-in-markdown, and lint:docs-relative-links pass before and after.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
- relevant API documentation, tutorials, and examples are updated and follow the documentation style guide
Release Notes
Notes: none
🤖 Generated with Claude Code
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron