Skip to content

Cleanup: Unify oxlint at root and add more file to format#34245

Merged
huang-julien merged 28 commits into
nextfrom
chore/root_oxfmt
Mar 24, 2026
Merged

Cleanup: Unify oxlint at root and add more file to format#34245
huang-julien merged 28 commits into
nextfrom
chore/root_oxfmt

Conversation

@huang-julien
Copy link
Copy Markdown
Contributor

@huang-julien huang-julien commented Mar 20, 2026

What I did

  • move oxfmt to a single config at the root
    • moving subrepos fmt command to root. lint commands will be moved to root and then we'll delete lint + fmt commands in sub repos
  • keep for md, mdx excluded
    • assses if we fmt them in another PR
  • Keep yml, yaml excluded
  • keep test-storybooks excluded
  • Enable fmt for .* dirs
  • move lint-staged to root.

todo in follow-up PR:

  • remove sort-package-json since it's already handled by oxfmt
  • check with DX team on formatting docs
  • check with DX team on formatting ymlz

Checklist for Contributors

Testing

  • Verify that MDX changes didn't broke documentations.
  • Verify that CI didn't break with yml formatting

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

  • check that MD files are correctly formated

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Chores
    • Migrated formatting to oxfmt and added workspace-level format scripts/checks.
    • Consolidated staged lint/format configuration at the workspace root and removed per-package staged configs.
    • Simplified pre-commit hook to a single format/lint invocation.
    • Updated linting/formatting flows and CI steps to use oxfmt.
    • Updated recommended VS Code extension and editor formatter/settings for JS/TS/React and JSON.

@huang-julien huang-julien self-assigned this Mar 20, 2026
@huang-julien huang-julien added ci:normal cleanup Minor cleanup style change that won't show up in release changelog labels Mar 20, 2026
@huang-julien huang-julien marked this pull request as draft March 20, 2026 14:01
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Mar 20, 2026

View your CI Pipeline Execution ↗ for commit c9ad52a

Command Status Duration Result
nx run-many -t compile,check,knip,test,lint,san... ✅ Succeeded 8m 41s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-24 14:32:56 UTC

@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented Mar 20, 2026

Package Benchmarks

Commit: c9ad52a, ran on 24 March 2026 at 14:35:53 UTC

No significant changes detected, all good. 👏

@huang-julien huang-julien changed the title Cleanup: Move oxfmt to oonly root config and add more file to format Cleanup: Unify oxlint at root and add more file to format Mar 20, 2026
@huang-julien huang-julien marked this pull request as ready for review March 20, 2026 16:17
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Repository-wide toolchain migration: Prettier replaced by oxfmt/oxc; root formatter config and VS Code defaults added; per-package formatter cleaned/removed; lint-staged consolidated at root; Husky pre-commit simplified to a single yarn lint-staged; package scripts and CI updated to use oxfmt and workspace-aware lint commands. (44 words)

Changes

Cohort / File(s) Summary
Root formatter & VS Code
/.oxfmtrc.json, /.vscode/settings.json, /.vscode/extensions.json
Added root .oxfmtrc.json with $schema, overrides, and new ignorePatterns; switched VS Code default formatter to oxc.oxc-vscode, recommended the extension, and added oxc settings.
Removed/changed per-package formatter configs
code/.oxfmtrc.json, docs/.oxfmtrc.json
Deleted code/.oxfmtrc.json; updated docs/.oxfmtrc.json to include schema and oxfmt options (tabWidth, trailingComma, arrowParens, embeddedLanguageFormatting).
Husky hook simplification
/.husky/pre-commit
Removed per-directory cd steps; pre-commit now runs a single yarn lint-staged when SKIP_STORYBOOK_GIT_HOOKS is unset.
Workspace lint-staged & formatting scripts
/package.json, code/package.json, scripts/package.json
Moved/added lint-staged to root package.json with globs invoking oxfmt --check and workspace lint commands; added fmt:check/fmt:write scripts; removed package-local lint-staged config and dependency from code and scripts.
CI and project targets
scripts/ci/common-jobs.ts, scripts/project.json
CI job steps changed to run yarn fmt:check (oxfmt) and use npm.install('.'); pretty-docs target now runs yarn fmt:check with explicit cwd and includes docs/.oxfmtrc.json in cache inputs.
code package script changes
code/package.json
Removed lint:fmt/lint:other and lint-staged dep; updated lint to yarn lint:js && cd .. && yarn fmt:check.
Dev deps & resolutions
/package.json (root)
Replaced prettier with oxfmt; added oxfmt and lint-staged to devDependencies/resolutions; added postinstall husky hook and adjusted scripts (pretty-docs, storybook-related entries).
Minor code/style tweaks
code/builders/.../iframe.html, code/core/src/manager/components/sidebar/Menu.tsx
Whitespace/indentation change in iframe.html; refactored styled interpolation structure in Menu.tsx (no API changes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
scripts/ci/common-jobs.ts (1)

74-78: prettyDocs is no longer docs-scoped.

Lines 74-78 now install from the workspace root and run the root yarn fmt:check, so this lane can fail on unrelated repo files instead of just docs/_snippets. If the intent is still a dedicated docs check, keep this job pointed at the scripts package formatter.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/ci/common-jobs.ts` around lines 74 - 78, The prettyDocs job currently
runs npm.install('.') and executes the root 'yarn fmt:check', which causes
formatting failures across the whole repo; change the job to target the
docs/scripts workspace instead (e.g., replace npm.install('.') with
npm.install('packages/scripts') or install the workspace containing the docs)
and/or run the package-scoped formatter command instead of the root formatter
(replace the 'yarn fmt:check' run command with the scripts package's formatter
such as a workspace or package-specific script) so prettyDocs only checks
docs/_snippets as intended; update references in the prettyDocs job where
npm.install('.') and the run.command 'yarn fmt:check' appear.
package.json (1)

44-62: The lint-staged scope is intentionally narrower than CI formatter coverage.

Lines 45–55 only run oxfmt --check for code/**/* files, while the root fmt:check script covers the entire repository (except ignored paths). This design means root-level files like package.json and scripts/**/* are formatted on CI (npm run fmt:check) but not validated at the pre-commit hook stage. If stricter pre-commit validation is desired, consider adding oxfmt --check tasks for non-code files to the lint-staged config. However, .vscode is intentionally excluded by .oxfmtrc.json ignore patterns and does not need formatter coverage.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 44 - 62, The lint-staged config in package.json
currently runs "oxfmt --check" only for the "code/**/*.{js,jsx,mjs,ts,tsx}" and
"code/**/*.{html,json}" globs, leaving root-level and scripts files un-checked
pre-commit; update the "lint-staged" entries to include "oxfmt --check" for the
non-code globs (e.g., add "oxfmt --check" to the
"scripts/**/*.{html,js,json,jsx,mjs,ts,tsx}" and "**/package.json" tasks or
create a new glob covering root-level files) so that the pre-commit hook mirrors
the repository-wide formatting enforced by the "fmt:check" script; keep existing
exclusions handled by .oxfmtrc.json (such as .vscode).
.oxfmtrc.json (1)

38-51: Dead configuration: MD/MDX override will never apply.

MD and MDX files are listed in ignorePatterns (lines 38-39), so the override block for *.md and *.mdx (lines 42-51) is unreachable—ignored files won't be processed by the formatter at all.

If the intent is to exclude MD/MDX for now (as stated in the PR objectives), consider removing the unused override block to avoid confusion. If you plan to re-enable MD/MDX formatting later, you could add a comment explaining why the override is kept.

🧹 Suggested cleanup: remove dead override
     "*.md",
     "*.mdx"
   ],
-  "overrides": [
-    {
-      "files": [
-        "*.md",
-        "*.mdx"
-      ],
-      "options": {
-        "importOrderSeparation": false,
-        "importOrderSortSpecifiers": false
-      }
-    },
+  "overrides": [
     {
       "files": [
         "*.component.html"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.oxfmtrc.json around lines 38 - 51, The overrides block for "*.md" and
"*.mdx" is dead because those patterns are already present in ignorePatterns, so
remove the unused overrides entry (the object containing "files":
["*.md","*.mdx"] and its "options") to avoid confusion; alternatively, if you
intend to keep it for future re-enabling, add a clear inline comment above that
overrides object explaining why MD/MDX are currently ignored and when to restore
the override, referencing the ignorePatterns and overrides keys so reviewers can
find the related configuration quickly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@code/builders/builder-vite/input/iframe.html`:
- Around line 84-88: The injected fallback HTML assigned to
document.getElementById('storybook-root').innerHTML contains a mismatched tag:
the list opens with <ul> twice; update the second opening <ul> at the end of the
template string to a closing </ul> so the markup produced by
message.replaceAll(...) and docs.map(...) results in a valid <ul>...</ul> list.

In `@scripts/project.json`:
- Around line 7-8: The pretty-docs target's caching is too narrow: it declares
inputs like docs/**/* but its command runs "yarn fmt:check" with cwd
"{workspaceRoot}" (which runs the root formatter over the whole repo), causing
stale cache hits; fix by either changing the command to use the docs-scoped
formatter (use the fmt:check script defined in scripts/package.json instead of
the root formatter) so the command only checks docs, or widen the target inputs
to include all files checked by the root formatter (e.g.,
"{workspaceRoot}/**/*") so the cache reflects the full command scope; update the
pretty-docs target's "command" and/or its inputs accordingly.

---

Nitpick comments:
In @.oxfmtrc.json:
- Around line 38-51: The overrides block for "*.md" and "*.mdx" is dead because
those patterns are already present in ignorePatterns, so remove the unused
overrides entry (the object containing "files": ["*.md","*.mdx"] and its
"options") to avoid confusion; alternatively, if you intend to keep it for
future re-enabling, add a clear inline comment above that overrides object
explaining why MD/MDX are currently ignored and when to restore the override,
referencing the ignorePatterns and overrides keys so reviewers can find the
related configuration quickly.

In `@package.json`:
- Around line 44-62: The lint-staged config in package.json currently runs
"oxfmt --check" only for the "code/**/*.{js,jsx,mjs,ts,tsx}" and
"code/**/*.{html,json}" globs, leaving root-level and scripts files un-checked
pre-commit; update the "lint-staged" entries to include "oxfmt --check" for the
non-code globs (e.g., add "oxfmt --check" to the
"scripts/**/*.{html,js,json,jsx,mjs,ts,tsx}" and "**/package.json" tasks or
create a new glob covering root-level files) so that the pre-commit hook mirrors
the repository-wide formatting enforced by the "fmt:check" script; keep existing
exclusions handled by .oxfmtrc.json (such as .vscode).

In `@scripts/ci/common-jobs.ts`:
- Around line 74-78: The prettyDocs job currently runs npm.install('.') and
executes the root 'yarn fmt:check', which causes formatting failures across the
whole repo; change the job to target the docs/scripts workspace instead (e.g.,
replace npm.install('.') with npm.install('packages/scripts') or install the
workspace containing the docs) and/or run the package-scoped formatter command
instead of the root formatter (replace the 'yarn fmt:check' run command with the
scripts package's formatter such as a workspace or package-specific script) so
prettyDocs only checks docs/_snippets as intended; update references in the
prettyDocs job where npm.install('.') and the run.command 'yarn fmt:check'
appear.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f790951e-159c-4906-96f9-1c9ce25a7547

📥 Commits

Reviewing files that changed from the base of the PR and between 87733f1 and bdfd129.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • .husky/pre-commit
  • .oxfmtrc.json
  • .vscode/extensions.json
  • .vscode/settings.json
  • code/.oxfmtrc.json
  • code/builders/builder-vite/input/iframe.html
  • code/core/src/manager/components/sidebar/Menu.tsx
  • code/package.json
  • docs/.oxfmtrc.json
  • package.json
  • scripts/ci/common-jobs.ts
  • scripts/package.json
  • scripts/project.json
💤 Files with no reviewable changes (3)
  • code/.oxfmtrc.json
  • .husky/pre-commit
  • docs/.oxfmtrc.json

Comment thread code/builders/builder-vite/input/iframe.html Outdated
Comment thread scripts/project.json Outdated
Comment thread .vscode/settings.json Outdated
@huang-julien huang-julien requested a review from AriPerkkio March 23, 2026 09:11
@huang-julien huang-julien marked this pull request as draft March 23, 2026 14:26
@huang-julien huang-julien marked this pull request as ready for review March 23, 2026 14:27
Copy link
Copy Markdown
Member

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

LGTM!

@huang-julien huang-julien enabled auto-merge March 24, 2026 14:37
@huang-julien huang-julien merged commit b31240c into next Mar 24, 2026
124 checks passed
@huang-julien huang-julien deleted the chore/root_oxfmt branch March 24, 2026 15:03
@github-actions github-actions Bot mentioned this pull request Mar 24, 2026
15 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Mar 24, 2026
8 tasks
@JReinhold JReinhold added the build Internal-facing build tooling & test updates label Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Fails
🚫

Please choose only one of these labels: ["cleanup","build"]

Generated by 🚫 dangerJS against c9ad52a

@valentinpalkovic valentinpalkovic added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Mar 31, 2026
@github-actions github-actions Bot mentioned this pull request Mar 31, 2026
19 tasks
valentinpalkovic pushed a commit that referenced this pull request Mar 31, 2026
Cleanup: Unify oxlint at root and add more file to format
(cherry picked from commit b31240c)
@github-actions github-actions Bot mentioned this pull request Apr 2, 2026
19 tasks
@github-actions github-actions Bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal cleanup Minor cleanup style change that won't show up in release changelog patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants