mirror of
https://github.com/electron/electron.git
synced 2026-10-28 11:44:46 +08:00
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck
---------
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
bbe4cdfea4
commit
2f64d2b3a4
6 files changed
+10
-22
No files matched your search
+1
-3
@@ -1479,9 +1479,7 @@ For `infoType` equal to `complete`:
|
||||
For `infoType` equal to `basic`:
|
||||
Promise is fulfilled with `Object` containing fewer attributes than when requested with `complete`. Here's an example of basic response:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
```json5
|
||||
{
|
||||
auxAttributes:
|
||||
{
|
||||
|
||||
+2
-6
@@ -63,9 +63,7 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
|
||||
The `filters` specifies an array of file types that can be displayed or
|
||||
selected when you want to limit the user to a specific type. For example:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
```json5
|
||||
{
|
||||
filters: [
|
||||
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] },
|
||||
@@ -151,9 +149,7 @@ The `window` argument allows the dialog to attach itself to a parent window, mak
|
||||
The `filters` specifies an array of file types that can be displayed or
|
||||
selected when you want to limit the user to a specific type. For example:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
```json5
|
||||
{
|
||||
filters: [
|
||||
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] },
|
||||
|
||||
@@ -12,9 +12,7 @@ The number represented by `status` means different things on different platforms
|
||||
Below is an example of some of the additional options that may be set which
|
||||
may be different on each platform.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
```json5
|
||||
{
|
||||
name: 'Austin_4th_Floor_Printer___C02XK13BJHD4',
|
||||
displayName: 'Austin 4th Floor Printer @ C02XK13BJHD4',
|
||||
|
||||
@@ -26,9 +26,7 @@
|
||||
|
||||
An example TraceConfig that roughly matches what Chrome DevTools records:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
```json5
|
||||
{
|
||||
recording_mode: 'record-until-full',
|
||||
included_categories: [
|
||||
|
||||
@@ -242,9 +242,7 @@ console.log(webFrame.getResourceUsage())
|
||||
|
||||
This will generate:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
```json5
|
||||
{
|
||||
images: {
|
||||
count: 22,
|
||||
|
||||
@@ -98,7 +98,7 @@ submenu, which aligns items horizontally (available on macOS 14 and above)
|
||||
> [!TIP]
|
||||
> Adjacent `radio` items are at the same level of submenu and not divided by a separator.
|
||||
>
|
||||
> ```js
|
||||
> ```json5
|
||||
> [
|
||||
> { type: 'radio', label: 'Adjacent 1' },
|
||||
> { type: 'radio', label: 'Adjacent 2' },
|
||||
@@ -236,7 +236,7 @@ positioning keywords is used.
|
||||
|
||||
Template:
|
||||
|
||||
```js
|
||||
```json5
|
||||
[
|
||||
{ id: '1', label: 'one' },
|
||||
{ id: '2', label: 'two' },
|
||||
@@ -256,7 +256,7 @@ Menu:
|
||||
|
||||
Template:
|
||||
|
||||
```js
|
||||
```json5
|
||||
[
|
||||
{ id: '1', label: 'one' },
|
||||
{ type: 'separator' },
|
||||
@@ -280,7 +280,7 @@ Menu:
|
||||
|
||||
Template:
|
||||
|
||||
```js
|
||||
```json5
|
||||
[
|
||||
{ id: '1', label: 'one', after: ['3'] },
|
||||
{ id: '2', label: 'two', before: ['1'] },
|
||||
|
||||
Reference in new issue
Block a user