chore: migrate from Prettier to oxfmt for code formatting#11824
chore: migrate from Prettier to oxfmt for code formatting#11824slorber merged 10 commits intofacebook:mainfrom
Conversation
|
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.
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Great Idea. Was searching for something like this. |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
|
@yangshun let me know if you want to update this PR. Now that we upgraded node it should pass CI. |
|
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. |
Replace prettier invocation in per-package build scripts and refresh yarn.lock after switching from prettier to oxfmt.
|
@slorber updated to latest Oxlint and rebased against
|
|
Thanks I'll test a bit the Oxc plugin for Intellij soon to see if this isn't disruptive for me, and merge asap 👍 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
slorber
left a comment
There was a problem hiding this comment.
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-ignoreexists 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-patternbecause 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\"", |
There was a problem hiding this comment.
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)
| "packages/docusaurus-*/lib/*", | ||
|
|
||
| "packages/create-docusaurus/lib/*", | ||
| "!packages/docusaurus-*/lib/theme/**", |
There was a problem hiding this comment.
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
Summary
.oxfmtrc.jsonconfiguration and remove.prettierrc/.prettierignoreTest plan
oxfmtformats all files correctlyNotes on CI
pull-requests: writeto post the sticky comment); the audit itself ran successfully.