Skip to content

chore: lint code blocks in docs with ESLint - #42113

Merged
VerteDinde merged 1 commit into
mainfrom
chore/eslint-code-blocks
May 29, 2025
Merged

VerteDinde merged 1 commit into
mainfrom
chore/eslint-code-blocks

Conversation

@dsanders11

@dsanders11 dsanders11 commented May 10, 2024 •

Copy link
Copy Markdown
Member

Description of Change

Main motivation at the moment is to run unicorn/prefer-node-protocol over the code blocks, but it may also catch some other errors as well.

cc @electron/docs

Checklist

  • PR description included and stakeholders cc'd

Release Notes

Notes: none

@electron-cation electron-cation Bot added new-pr 🌱 PR opened recently and removed new-pr 🌱 PR opened recently labels May 10, 2024
@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch from 925a227 to f448ad2 Compare June 26, 2024 01:27
@dsanders11
dsanders11 marked this pull request as ready for review June 26, 2024 02:50
@dsanders11
dsanders11 marked this pull request as draft June 26, 2024 02:52
@electron-cation electron-cation Bot added new-pr 🌱 PR opened recently and removed new-pr 🌱 PR opened recently labels Jun 26, 2024
@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch from 3a0ce70 to 469c00e Compare August 13, 2024 21:11
@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch 2 times, most recently from 6539312 to 9ad8bc7 Compare October 4, 2024 23:05
@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch from 9ad8bc7 to 210f1a4 Compare October 21, 2024 21:55
@dsanders11
dsanders11 marked this pull request as ready for review October 21, 2024 23:41
@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch from 210f1a4 to 502940b Compare November 12, 2024 22:17
@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch from 502940b to a306f00 Compare May 27, 2025 07:54
Comment thread docs/.eslintrc.json
Comment on lines +13 to +33
"@typescript-eslint/no-unused-vars": "off",
"indent": "off",
"no-undef": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
"semi": "off",
"unicorn/prefer-node-protocol": "error"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we extends: standard as shorthand here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added that and dropped a couple of these rules (semi: off and indent: off) by excluding a couple more blocks from specific ESLint rules. The rest of these are actually the inverse of what they'd be in standard, specifically turning off unused/undefined checking because a lot of our code blocks are fragments which trip those rules, and that's fine for docs.

@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch 2 times, most recently from ba5bc0b to 0661b7b Compare May 28, 2025 05:03
@dsanders11
dsanders11 force-pushed the chore/eslint-code-blocks branch from 0661b7b to 390fb12 Compare May 28, 2025 21:36
@VerteDinde
VerteDinde merged commit 0d70389 into main May 29, 2025
@VerteDinde
VerteDinde deleted the chore/eslint-code-blocks branch May 29, 2025 19:45
@release-clerk

release-clerk Bot commented May 29, 2025

Copy link
Copy Markdown

No Release Notes

@dsanders11 dsanders11 mentioned this pull request May 29, 2025
1 task done
kigh-ota pushed a commit to kigh-ota/electron that referenced this pull request Sep 30, 2025
PKRoma pushed a commit to PKRoma/electron that referenced this pull request Apr 5, 2026
Consolidates the root .eslintrc.json and five nested configs (build,
script, docs, default_app, spec) into a single .oxlintrc.json at the
repo root. script/lint.js now shells out to the oxlint binary from
node_modules/.bin instead of using the ESLint Node API, and emits
GitHub Actions annotations directly via --format=github in CI
(replacing the deleted eslint-stylish problem matcher).

Oxlint has no markdown processor, so the ESLint-based lint of JS code
blocks in docs/**/*.md is replaced with an inline regex check for bare
Node.js builtin imports. This preserves the rule docs/.eslintrc.json
was originally added for in electron#42113; the rest of the standard ruleset on
docs code blocks was already being enforced in parallel by
lint-roller-markdown-standard.
MarshallOfSound added a commit that referenced this pull request Apr 6, 2026
Consolidates the root .eslintrc.json and five nested configs (build,
script, docs, default_app, spec) into a single .oxlintrc.json at the
repo root. script/lint.js now shells out to the oxlint binary from
node_modules/.bin instead of using the ESLint Node API, and emits
GitHub Actions annotations directly via --format=github in CI
(replacing the deleted eslint-stylish problem matcher).

Oxlint has no markdown processor, so the ESLint-based lint of JS code
blocks in docs/**/*.md is replaced with an inline regex check for bare
Node.js builtin imports. This preserves the rule docs/.eslintrc.json
was originally added for in #42113; the rest of the standard ruleset on
docs code blocks was already being enforced in parallel by
lint-roller-markdown-standard.
jkleinsc pushed a commit that referenced this pull request Oct 19, 2026
* docs: fix code block line highlighting after lint reformats

Several highlighted code blocks in the IPC and preload tutorials had their
line-highlight ranges drift when the docs code blocks were auto-formatted
(the `import/order` blank line added in #42113, and the if/else collapse in
#38260), so the highlights now land one line off from the code they were
meant to call out. Update the ranges to point back at the originally
highlighted code without changing the code blocks themselves.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

* docs: fix code block line highlighting that drifted from content edits

The Playwright examples in automated-testing.md lost a line when their two
`require` statements were merged, leaving the highlights one line late, and
the code signing examples replaced a two-line certificate option with a
`windowsSign` object while keeping the old two-line ranges. Point the
highlights back at the intended code and cover the whole `windowsSign`
object.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

---------

Co-authored-by: Claude <[email protected]>
jkleinsc pushed a commit that referenced this pull request Oct 19, 2026
* docs: fix code block line highlighting after lint reformats

Several highlighted code blocks in the IPC and preload tutorials had their
line-highlight ranges drift when the docs code blocks were auto-formatted
(the `import/order` blank line added in #42113, and the if/else collapse in
#38260), so the highlights now land one line off from the code they were
meant to call out. Update the ranges to point back at the originally
highlighted code without changing the code blocks themselves.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

* docs: fix code block line highlighting that drifted from content edits

The Playwright examples in automated-testing.md lost a line when their two
`require` statements were merged, leaving the highlights one line late, and
the code signing examples replaced a two-line certificate option with a
`windowsSign` object while keeping the old two-line ranges. Point the
highlights back at the intended code and cover the whole `windowsSign`
object.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
dsanders11 pushed a commit that referenced this pull request Oct 19, 2026
* docs: fix code block line highlighting after lint reformats

Several highlighted code blocks in the IPC and preload tutorials had their
line-highlight ranges drift when the docs code blocks were auto-formatted
(the `import/order` blank line added in #42113, and the if/else collapse in
#38260), so the highlights now land one line off from the code they were
meant to call out. Update the ranges to point back at the originally
highlighted code without changing the code blocks themselves.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

* docs: fix code block line highlighting that drifted from content edits

The Playwright examples in automated-testing.md lost a line when their two
`require` statements were merged, leaving the highlights one line late, and
the code signing examples replaced a two-line certificate option with a
`windowsSign` object while keeping the old two-line ranges. Point the
highlights back at the intended code and cover the whole `windowsSign`
object.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
dsanders11 pushed a commit that referenced this pull request Oct 19, 2026
* docs: fix code block line highlighting after lint reformats

Several highlighted code blocks in the IPC and preload tutorials had their
line-highlight ranges drift when the docs code blocks were auto-formatted
(the `import/order` blank line added in #42113, and the if/else collapse in
#38260), so the highlights now land one line off from the code they were
meant to call out. Update the ranges to point back at the originally
highlighted code without changing the code blocks themselves.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

* docs: fix code block line highlighting that drifted from content edits

The Playwright examples in automated-testing.md lost a line when their two
`require` statements were merged, leaving the highlights one line late, and
the code signing examples replaced a two-line certificate option with a
`windowsSign` object while keeping the old two-line ranges. Point the
highlights back at the intended code and cover the whole `windowsSign`
object.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
dsanders11 pushed a commit that referenced this pull request Oct 20, 2026
* docs: fix code block line highlighting after lint reformats

Several highlighted code blocks in the IPC and preload tutorials had their
line-highlight ranges drift when the docs code blocks were auto-formatted
(the `import/order` blank line added in #42113, and the if/else collapse in
#38260), so the highlights now land one line off from the code they were
meant to call out. Update the ranges to point back at the originally
highlighted code without changing the code blocks themselves.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

* docs: fix code block line highlighting that drifted from content edits

The Playwright examples in automated-testing.md lost a line when their two
`require` statements were merged, leaving the highlights one line late, and
the code signing examples replaced a two-line certificate option with a
`windowsSign` object while keeping the old two-line ranges. Point the
highlights back at the intended code and cover the whole `windowsSign`
object.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01A9enZ3jn8BveASiB5p9G1E

Co-authored-by: Claude <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants