Skip to content

chore: migrate from Prettier to oxfmt for code formatting#11824

Merged
slorber merged 10 commits intofacebook:mainfrom
yangshun:ys/oxfmt
May 7, 2026
Merged

chore: migrate from Prettier to oxfmt for code formatting#11824
slorber merged 10 commits intofacebook:mainfrom
yangshun:ys/oxfmt

Conversation

@yangshun
Copy link
Copy Markdown
Contributor

@yangshun yangshun commented Mar 20, 2026

Summary

  • Replace Prettier with oxfmt as the code formatter
  • Add .oxfmtrc.json configuration and remove .prettierrc / .prettierignore
  • Update lint-staged config, CI workflows, and VS Code extensions accordingly
  • Reformat codebase with oxfmt

Test plan

  • Verify oxfmt formats all files correctly
  • Verify CI lint workflow passes
  • Verify lint-staged works on pre-commit

Notes on CI

  • Argos: 1 visual diff is reported and is intended — caused by oxfmt reflowing some MDX content (e.g. footnote spacing, list item spacing, ternary indentation in code blocks). Please approve the Argos build to accept the new baseline.
  • Lighthouse Report: failure is environmental (fork PRs lack pull-requests: write to post the sticky comment); the audit itself ran successfully.

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Mar 20, 2026
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Mar 20, 2026

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: ?npm/@docusaurus/core@3.10.1npm/@docusaurus/preset-classic@3.10.1npm/entities@4.5.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@4.5.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: ?npm/@docusaurus/core@3.10.1npm/@docusaurus/preset-classic@3.10.1npm/entities@6.0.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@6.0.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 20, 2026

[V2]

Name Link
🔨 Latest commit 296451d
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69fc7a7dde7df70008572059
😎 Deploy Preview https://deploy-preview-11824--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@akshatsinha0
Copy link
Copy Markdown
Contributor

Great Idea. Was searching for something like this.

@yangshun yangshun marked this pull request as ready for review April 8, 2026 15:14
@yangshun yangshun marked this pull request as draft April 8, 2026 15:19
@slorber slorber added pr: maintenance This PR does not produce any behavior differences to end users when upgrading. Argos Add this label to run UI visual regression tests. See argos.yml GH action. labels Apr 8, 2026
@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 changed May 7, 2026, 11:49 AM

@slorber
Copy link
Copy Markdown
Collaborator

slorber commented Apr 28, 2026

@yangshun let me know if you want to update this PR. Now that we upgraded node it should pass CI.

@yangshun
Copy link
Copy Markdown
Contributor Author

Sorry I dropped the ball on this, I'll update this PR within the next few days. Or if you want to take over go ahead as well.

@yangshun yangshun marked this pull request as ready for review April 29, 2026 10:37
@yangshun
Copy link
Copy Markdown
Contributor Author

yangshun commented Apr 29, 2026

@slorber updated to latest Oxlint and rebased against origin/main. I eyeballed the rest of the changes, they look fine.

  • Lighthouse failure: Seems to fail for all non-maintainer PRs
  • Argos failure: Intended as the formatting of some code blocks have changed, and the Argos screenshot captures that difference. I'm not sure how to update on my end. Can I trouble you to make the necessary updates?

@slorber
Copy link
Copy Markdown
Collaborator

slorber commented Apr 30, 2026

Thanks

I'll test a bit the Oxc plugin for Intellij soon to see if this isn't disruptive for me, and merge asap 👍

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 7, 2026

Copy link
Copy Markdown
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Additional notes:

  • Removed the prettier xml plugin
  • Kept https://github.com/prettier/stylelint-config-prettier, also works to avoid css conflicts with oxfmt, but we'll likely be able to remove it after upgrading Stylelint
  • // oxfmt-ignore exists but do not work everywhere. For now, it's safer to use // prettier-ignore, also supported (see oxc-project/website#1092)
  • Removed --no-error-on-unmatched-pattern because otherwise it hides a bug: theme JS files are not pretty when swizzling them as JS. We want to ensure they remain formatted after the migration.

Otherwise it looks good and fast 👍

"types": "src/plugin-ideal-image.d.ts",
"scripts": {
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && oxfmt \"lib/theme/**/*.js\"",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

FYI I removed the --no-error-on-unmatched-pattern on purpose

lib files are usually generated/ignored, but for lib/theme we definitely want to format them well because it's what users will get when swizzling with JS. (for TS we swizzle from source so it's already formatted)

Comment thread .oxfmtrc.json
"packages/docusaurus-*/lib/*",

"packages/create-docusaurus/lib/*",
"!packages/docusaurus-*/lib/theme/**",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Needed to format js files for js swizzle CLI, otherwise we get an error without --no-error-on-unmatched-pattern because oxfmt doesn't format them

@slorber slorber merged commit 190ef6f into facebook:main May 7, 2026
36 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Argos Add this label to run UI visual regression tests. See argos.yml GH action. CLA Signed Signed Facebook CLA pr: maintenance This PR does not produce any behavior differences to end users when upgrading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants