Skip to content

build: add oxfmt for JS/TS formatting and import sorting - #50692

Merged
MarshallOfSound merged 2 commits into
mainfrom
chore/add-oxfmt
Apr 12, 2026
Merged

MarshallOfSound merged 2 commits into
mainfrom
chore/add-oxfmt

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Apr 5, 2026 •

Copy link
Copy Markdown
Member

Adds oxfmt alongside oxlint and applies it to the JS/TS sources. Follows #50691.

Commit 1 wires it in:

  • .oxfmtrc.json matching existing repo style (single quotes, semicolons, 2-space) with sortImports.customGroups mirroring the old import/order pathGroups for @electron/internal, @electron/*, and electron
  • yarn lint:fmt (oxfmt --check) chained into yarn lint so CI enforces it
  • yarn format (oxfmt --write) for local fixup
  • lint-staged runs oxfmt --write on staged .{js,ts,mjs,cjs} ahead of oxlint

Commit 2 is the one-time yarn format over 297 files. Pure formatting; review with whitespace hidden.

yarn lint:fmt over 571 files: ~555ms.

Notes: none

@socket-security

socket-security Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedoxfmt@​0.42.0901008996100

View full report

@MarshallOfSound MarshallOfSound added target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Apr 5, 2026
Base automatically changed from chore/migrate-eslint-to-oxlint to main April 6, 2026 16:05
@MarshallOfSound
MarshallOfSound requested a review from a team as a code owner April 6, 2026 16:05

@clavin clavin left a comment

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.

Clean 👍

Checked the setup commit & skimmed through the reformat commit. Overall looks good and happy merging as-is. Left some ideas for polish.

P.S. this is a good candidate for .git-blame-ignore-revs

Comment thread lib/browser/api/base-window.ts Resolved
Comment thread .oxfmtrc.json Resolved
Adds oxfmt as a devDependency alongside oxlint and wires it into the
lint pipeline. The .oxfmtrc.json config matches Electron's current JS
style (single quotes, semicolons, 2-space indent, trailing commas off,
printWidth 100) and configures sortImports with custom groups that
mirror the import/order pathGroups previously enforced by ESLint:
@electron/internal, @electron/*, and {electron,electron/**} each get
their own ordered group ahead of external modules.

- `yarn lint:fmt` runs `oxfmt --check` over JS/TS sources and is
  chained into `yarn lint` so CI enforces it automatically.
- `yarn format` runs `oxfmt --write` for local fix-up.
- lint-staged invokes `oxfmt --write` on staged .js/.ts/.mjs/.cjs
  files before oxlint, so formatting is applied at commit time.

The next commit applies the formatter to the existing codebase so the
check actually passes.
@MarshallOfSound

Copy link
Copy Markdown
Member Author

Good call on .git-blame-ignore-revs — will add it in a follow-up once this lands and the format-commit SHA is final.

Runs `yarn format` across lib/, spec/, script/, build/, default_app/,
and npm/ to bring the codebase in line with the .oxfmtrc.json settings
added in the previous commit. This is a pure formatting pass: import
statements are sorted into the groups defined by the config, method
chains longer than printWidth are broken, single-quoted strings
containing apostrophes are switched to double quotes, and a handful of
single-statement `if` bodies are re-wrapped and get braces added by
`oxlint --fix` to satisfy the `curly: multi-line` rule.

No behavior changes.
@MarshallOfSound
MarshallOfSound merged commit 2c94aac into main Apr 12, 2026
64 of 65 checks passed
@release-clerk

release-clerk Bot commented Apr 12, 2026

Copy link
Copy Markdown

No Release Notes

@MarshallOfSound
MarshallOfSound deleted the chore/add-oxfmt branch April 12, 2026 09:03
@trop

trop Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "42-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot removed the target/42-x-y PR should also be added to the "42-x-y" branch. label Apr 12, 2026
@trop

trop Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "40-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "39-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot removed the target/40-x-y PR should also be added to the "40-x-y" branch. label Apr 12, 2026
@trop

trop Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "41-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/40-x-y and removed target/41-x-y PR should also be added to the "41-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. labels Apr 12, 2026
@trop

trop Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

@ckerr has manually backported this PR to "41-x-y", please check out #51443

MarshallOfSound pushed a commit that referenced this pull request May 2, 2026
* build: replace eslint with oxlint and add oxfmt

Replace ESLint and its plugin ecosystem with oxlint (oxc.rs).
Add oxfmt alongside oxlint for JS/TS formatting and import sorting.

- Consolidate root .eslintrc.json plus 13 nested configs into .oxlintrc.json
- script/lint.js spawns oxlint binary directly instead of ESLint Node API
- Per-process no-restricted-imports rules preserved as oxlintrc overrides
- mocha/no-exclusive-tests replaced by in-repo plugin (no-only-tests.mjs)
- docs ESLint pass replaced by inline node: protocol check in lint.js
- .oxfmtrc.json matching repo style (single quotes, semicolons, 2-space)
- yarn lint:fmt (oxfmt --check) chained into yarn lint
- yarn format (oxfmt --write) for local fixup
- lint-staged runs oxfmt --write on staged JS/TS files

This commit contains only rule/tooling infrastructure changes and is
intended to be cherry-picked to other maintenance branches, where
formatting and lint fixes can be applied separately.

Manual backport of e1af67c698 (#50691) and
3c7fd34f47 (#50692).

* chore: apply oxfmt formatting and oxlint fixes

One-time application of the new linting and formatting rules to the
41-x-y codebase:

- yarn format (oxfmt --write) over all JS/TS sources
- oxlint --fix to restore curly braces where oxfmt removed them
- Prefix unused parameters with _ (no-unused-vars)
- Add eslint-disable-next-line comments for intentional patterns:
  - prefer-promise-reject-errors in desktop-capturer.ts
  - no-throw-literal in preload.ts
  - no-only-tests/no-only-tests in spec-helpers.ts
- Restore bare require() in preload-sandbox.js test assertions
  (oxfmt incorrectly converted bare specifiers to node: protocol,
  defeating the equivalence test)

Pure formatting and lint suppression; no behavioral changes.
@trop trop Bot added merged/41-x-y PR was merged to the "41-x-y" branch. and removed in-flight/41-x-y labels May 2, 2026
MarshallOfSound pushed a commit that referenced this pull request May 2, 2026
* build: replace eslint with oxlint and add oxfmt

Replace ESLint and its plugin ecosystem with oxlint (oxc.rs).
Add oxfmt alongside oxlint for JS/TS formatting and import sorting.

- Consolidate root .eslintrc.json plus 13 nested configs into .oxlintrc.json
- script/lint.js spawns oxlint binary directly instead of ESLint Node API
- Per-process no-restricted-imports rules preserved as oxlintrc overrides
- mocha/no-exclusive-tests replaced by in-repo plugin (no-only-tests.mjs)
- docs ESLint pass replaced by inline node: protocol check in lint.js
- .oxfmtrc.json matching repo style (single quotes, semicolons, 2-space)
- yarn lint:fmt (oxfmt --check) chained into yarn lint
- yarn format (oxfmt --write) for local fixup
- lint-staged runs oxfmt --write on staged JS/TS files

This commit contains only rule/tooling infrastructure changes and is
intended to be cherry-picked to other maintenance branches, where
formatting and lint fixes can be applied separately.

Manual backport of e1af67c698 (#50691) and
3c7fd34f47 (#50692).

* chore: apply oxfmt formatting and oxlint fixes

One-time application of the new linting and formatting rules to the
42-x-y codebase:

- yarn format (oxfmt --write) over all JS/TS sources
- oxlint --fix to restore curly braces where oxfmt removed them
- Prefix unused parameters with _ (no-unused-vars)
- Add eslint-disable-next-line comments for intentional patterns:
  - prefer-promise-reject-errors in desktop-capturer.ts
  - no-throw-literal in preload.ts

Pure formatting and lint suppression; no behavioral changes.
@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 May 2, 2026
@ckerr ckerr mentioned this pull request May 5, 2026
5 tasks done
@trop

trop Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@ckerr has manually backported this PR to "40-x-y", please check out #51500

MarshallOfSound pushed a commit that referenced this pull request May 7, 2026
* build: replace eslint with oxlint and add oxfmt

Replace ESLint and its plugin ecosystem with oxlint (oxc.rs).
Add oxfmt alongside oxlint for JS/TS formatting and import sorting.

- Consolidate root .eslintrc.json plus 13 nested configs into .oxlintrc.json
- script/lint.js spawns oxlint binary directly instead of ESLint Node API
- Per-process no-restricted-imports rules preserved as oxlintrc overrides
- mocha/no-exclusive-tests replaced by in-repo plugin (no-only-tests.mjs)
- docs ESLint pass replaced by inline node: protocol check in lint.js
- .oxfmtrc.json matching repo style (single quotes, semicolons, 2-space)
- yarn lint:fmt (oxfmt --check) chained into yarn lint
- yarn format (oxfmt --write) for local fixup
- lint-staged runs oxfmt --write on staged JS/TS files

This commit contains only rule/tooling infrastructure changes and is
intended to be cherry-picked to other maintenance branches, where
formatting and lint fixes can be applied separately.

Manual backport of e1af67c698 (#50691) and
3c7fd34f47 (#50692).

* chore: apply oxfmt and oxlint formatting changes

Run oxfmt --write and oxlint --fix across all JS/TS sources to
apply the new formatting and lint rules from the previous commit.

* chore: remove accidentally-included CLAUDE.md
@trop trop Bot added merged/40-x-y PR was merged to the "40-x-y" branch. and removed in-flight/40-x-y labels May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants