Skip to content

docs: use json5 for bare object literal code blocks - #54107

Merged
MarshallOfSound merged 3 commits into
mainfrom
docs/json5-object-literal-blocks
Sep 19, 2026
Merged

MarshallOfSound merged 3 commits into
mainfrom
docs/json5-object-literal-blocks

Conversation

@claude

@claude claude Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Release Notes

Notes: none

🤖 Generated with Claude Code

https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck

Several docs code blocks contain only a bare object literal (an example
return value or options object) but are tagged as `js`. As JavaScript,
`{ key: value, ... }` on its own is a block statement, not an object, so
standard/ESLint reports "Parsing error: Unexpected token :" on most of
them; they only lint today because @electron/lint-roller special-cases
them with a regex that wraps orphan `{...}` blocks in parens before
linting. The blocks are valid JSON5, so tag them as such and drop the
`<!-- eslint-skip -->` comments that preceded them, which nothing in the
current tooling honors.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck
@electron-cation electron-cation Bot added documentation 📓 semver/patch backwards-compatible bug fixes labels Sep 19, 2026
@claude claude Bot added semver/none and removed documentation 📓 semver/patch backwards-compatible bug fixes labels Sep 19, 2026
The three menu template examples in docs/tutorial/menus.md are bare
array literals, not runnable JavaScript. Like the bare object literal
blocks in the previous commit, they are valid JSON5, so tag them as
such instead of `js`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck
The radio menu item example in the `[!TIP]` blockquote in
docs/tutorial/menus.md is a bare array literal tagged `js`; it was
missed earlier because the fence is prefixed with `> `. It is valid
JSON5 (including the trailing `//` comment), so tag it json5 like the
other bare literal blocks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck
@dsanders11 dsanders11 added target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 19, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 19, 2026 23:04
@MarshallOfSound
MarshallOfSound merged commit 2f64d2b into main Sep 19, 2026
66 checks passed
@MarshallOfSound
MarshallOfSound deleted the docs/json5-object-literal-blocks branch September 19, 2026 23:04
@release-clerk

release-clerk Bot commented Sep 19, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #54120

@trop

trop Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #54121

@trop trop Bot removed the target/44-x-y PR should also be added to the "44-x-y" branch. label Sep 19, 2026
@trop

trop Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #54122

@trop trop Bot added in-flight/43-x-y in-flight/45-x-y and removed target/43-x-y PR should also be added to the "43-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 19, 2026
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. and removed in-flight/44-x-y in-flight/43-x-y in-flight/45-x-y labels Sep 19, 2026
@trop

trop Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "42-x-y", please check out #54160

MarshallOfSound added a commit that referenced this pull request Sep 21, 2026
…ks with oxfmt (42-x-y) (#54160)

* docs: use json5 for bare object literal code blocks (#54107)

* docs: use json5 for bare object literal code blocks

Several docs code blocks contain only a bare object literal (an example
return value or options object) but are tagged as `js`. As JavaScript,
`{ key: value, ... }` on its own is a block statement, not an object, so
standard/ESLint reports "Parsing error: Unexpected token :" on most of
them; they only lint today because @electron/lint-roller special-cases
them with a regex that wraps orphan `{...}` blocks in parens before
linting. The blocks are valid JSON5, so tag them as such and drop the
`<!-- eslint-skip -->` comments that preceded them, which nothing in the
current tooling honors.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck

* docs: use json5 for bare array menu template blocks

The three menu template examples in docs/tutorial/menus.md are bare
array literals, not runnable JavaScript. Like the bare object literal
blocks in the previous commit, they are valid JSON5, so tag them as
such instead of `js`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck

* docs: use json5 for bare literal blocks nested in blockquotes

The radio menu item example in the `[!TIP]` blockquote in
docs/tutorial/menus.md is a bare array literal tagged `js`; it was
missed earlier because the fence is prefixed with `> `. It is valid
JSON5 (including the trailing `//` comment), so tag it json5 like the
other bare literal blocks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck

---------

Co-authored-by: Claude <[email protected]>
(cherry picked from commit 2f64d2b)

* build(deps-dev): bump oxlint from 1.57.0 to 1.80.0 (#53431)

* build(deps-dev): bump oxlint from 1.57.0 to 1.80.0

Bumps [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint) from 1.57.0 to 1.80.0.
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.80.0/npm/oxlint)

---
updated-dependencies:
- dependency-name: oxlint
  dependency-version: 1.80.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: satisfy lint rule

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <[email protected]>
(cherry picked from commit 633785d)

* build: update @electron/lint-roller to 4.0.0 (#54139)

lint-roller 4 drops `lint-roller-markdown-standard` (and with it the
transitive eslint/standard dependency tree, roughly 1,900 lines of
yarn.lock) in favour of `lint-roller-markdown-oxlint`, which lints the JS
code blocks in docs/ with the repo's own oxlint and .oxlintrc.json. It
also makes `lint-roller-markdown-ts-check` work with TypeScript 6 and 7.

- `lint:js-in-markdown` now runs `lint-roller-markdown-oxlint`.
- `lint:docs-fiddles` ran the `standard` binary, which was only ever
  installed as a dependency of lint-roller 3, so it now runs oxlint over
  docs/fiddles instead. The dozen findings that surfaced (unused trailing
  callback parameters, one `require('path')`, one stale eslint-disable
  comment) are fixed in the fiddles, and the one tutorial that inlines an
  affected fiddle is kept in sync.
- The `<!-- eslint-... -->` HTML comments in docs were directives for
  lint-roller-markdown-standard and are removed, and the docs style guide
  no longer points at standard-markdown.

Co-authored-by: Claude <[email protected]>
(cherry picked from commit 5eefaea)

* build: check the formatting of docs code blocks with oxfmt (#54140)

* build: check the formatting of docs code blocks with oxfmt

lint-roller 4 splits the old `lint-roller-markdown-standard` into an
oxlint half and an oxfmt half. This wires up the second one:
`lint:fmt-in-markdown` runs `lint-roller-markdown-oxfmt` over docs/ as
part of `lint:docs`, using docs/.oxfmtrc.json, which matches the repo's
.oxfmtrc.json except that docs snippets keep their semicolon-free style.
`--fix` writes the formatted blocks back, and a block can opt out with
`@noformat` in its info string.

* docs: format code blocks with oxfmt

Result of `lint-roller-markdown-oxfmt --fix` with docs/.oxfmtrc.json, plus
the @ts-expect-error line anchors (and one Docusaurus highlight marker)
that moved with the reformat. The Babel output sample in the ESM guide and
the two excerpts of repo source in creating-api.md are marked @noformat,
and the contentTracing example passes an async callback instead of
wrapping an IIFE so that it does not need a leading semicolon.

---------

Co-authored-by: Claude <[email protected]>
(cherry picked from commit ad3a896)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <[email protected]>
@trop trop Bot added merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/42-x-y labels Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/none

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants