Skip to content

Build: Move prettier to oxfmt#34183

Merged
huang-julien merged 23 commits into
nextfrom
chore/oxfmt
Mar 19, 2026
Merged

Build: Move prettier to oxfmt#34183
huang-julien merged 23 commits into
nextfrom
chore/oxfmt

Conversation

@huang-julien
Copy link
Copy Markdown
Contributor

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

Closes #

What I did

This PR migrate prettier to oxfmt for perf improvements. Tried to keep most of our former rules to avoid having a gigantic PR.

@kasperpeulen should we also migrate codemods ? This maybe better to migrate later as everyone's not on oxfmt yet. If so I can revert the commit.
Same for scripts/tools ?

ℹ️ oxfmt also format mdx. This is an opportunity to re-enable mdx formatting in docs in another PR.

❓ should we also remove old prettier rules in a future PR to stick closer to oxlint rules from now on ?

Checklist for Contributors

Testing

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

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

Manual testing

Caution

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

  • Verify all formatter scritps runs correctly.

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
    • Switched project formatter from Prettier to Oxfmt, updated lint scripts and CI checks, and removed Prettier integrations and dependencies.
  • Config
    • Added Oxfmt configuration, updated editor settings, lint-staged and package scripts, and removed old Prettier config entries.
  • Documentation
    • Updated contributor and project guidance to reference the new formatter and commands.
  • Tests / Style
    • Normalized formatting in many tests and docs, updated inline snapshots and examples to reflect the new formatting and quotation style.

@huang-julien huang-julien marked this pull request as draft March 17, 2026 15:31
@huang-julien huang-julien added ci:normal build Internal-facing build tooling & test updates labels Mar 17, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Mar 17, 2026

View your CI Pipeline Execution ↗ for commit f9df5e7

Command Status Duration Result
nx run-many -t compile -c production --parallel=1 ✅ Succeeded 5m 33s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-19 10:02:15 UTC

@huang-julien
Copy link
Copy Markdown
Contributor Author

Had to revert codemods because pipeline was failing ?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 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

Replaces Prettier with oxfmt across the repo: adds .oxfmtrc.json files and oxfmt scripts, removes Prettier configs/dependencies/exports, updates editor/CI to use oxfmt, and updates scripts, generators, and many tests/snapshots to call or consume oxfmt-formatted output.

Changes

Cohort / File(s) Summary
Workflow & CI
.github/workflows/fork-checks.yml
Renamed job from "prettier" → "formatting" and changed CI step to run yarn lint:fmt (oxfmt) instead of Prettier.
Formatter Configs
.oxfmtrc.json, code/.oxfmtrc.json, code/.prettierignore (deleted), prettier.config.mjs (deleted), code/prettier.config.mjs (deleted), scripts/prettier.config.js (deleted)`
Added oxfmt config files and removed Prettier config/ignore files.
Editor Settings
.vscode/settings.json
Switched TypeScript default formatter to oxc.oxc-vscode and removed Prettier ignorePath entries.
Package Scripts & Dependencies
code/package.json, scripts/package.json
Added lint:fmt and devDependency oxfmt, removed Prettier-specific scripts/deps, and updated lint-staged to call oxfmt.
Codegen & Formatting Calls
code/core/scripts/generate-source-files.ts, code/lib/eslint-plugin/scripts/*, scripts/create-nx-sandbox-projects.ts, scripts/utils/tools-esm.ts, scripts/utils/tools.ts
Replaced Prettier imports/calls with oxfmt usage; adapted call signatures/return shapes and removed passing Prettier config objects.
ESLint & Tooling Config
scripts/.eslintrc.cjs, scripts/package.json
Removed Prettier plugin/extends and eslint-plugin-prettier deps; adjusted staged lint commands.
Docs & Contribution Guidance
CONTRIBUTING.md, AGENTS.md, .serena/memories/project_overview.md
Updated documentation and contributor guidance to reference oxfmt and new formatting commands.
Tests, Snapshots & Templates
code/lib/cli-storybook/src/..., code/lib/codemod/..., code/core/..., code/frameworks/..., code/renderers/..., many docs
Widespread snapshot and template formatting changes (quote style, template literal line breaks, inline snapshots); tests adjusted to mock/consume formatFileContent where needed.
Small Type/Formatting Edits
code/core/src/csf/story.ts, code/core/src/manager-api/modules/stories.ts, code/lib/eslint-plugin/src/index.ts
Minor type-parentheses, function formatting, import reorderings; one signature change removing Prettier config params from generate-source-files generators.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant Repo as Repository
  participant CI as GitHub Actions
  participant Scripts as Repo scripts (generators, linters)
  participant Oxfmt as oxfmt

  Dev->>Repo: push changes (oxfmt config, scripts, code)
  CI->>Repo: checkout
  CI->>Scripts: run `yarn lint:fmt`
  Scripts->>Oxfmt: format (filename/content, options)
  Oxfmt-->>Scripts: return { code: formattedContent }
  Scripts->>Repo: write formatted outputs / continue pipeline
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

📝 Coding Plan
  • Generate coding plan for human review comments

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: 1

🧹 Nitpick comments (3)
AGENTS.md (1)

237-237: Document file-specific formatting syntax for oxfmt.

The new instruction cd code && oxfmt formats the entire directory. While oxfmt supports file-specific formatting like oxfmt src/file.ts or oxfmt '**/*.{ts,tsx}', the documentation doesn't show this option. Consider adding an example for contributors who only want to format changed files.

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

In `@AGENTS.md` at line 237, The docs currently show only the global command "cd
code && oxfmt"; update AGENTS.md to document file-specific usage by adding
examples and patterns (e.g., "oxfmt src/file.ts" and "oxfmt '**/*.{ts,tsx}'")
and a short note about quoting/globbing for shells so contributors can run oxfmt
against a single changed file or a glob of files instead of the whole directory.
code/package.json (1)

46-53: Consider a catch-all staged oxfmt entry.

Oxfmt supports a much wider file set than these two patterns, and its lint-staged docs recommend a catch-all formatter entry. Keeping oxfmt scoped here leaves those other supported file types out of the pre-commit auto-fix path even though yarn lint:fmt will still process them in bulk. (oxc.rs)

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

In `@code/package.json` around lines 46 - 53, The lint-staged config currently
limits oxfmt to two glob patterns ("*.{js,jsx,mjs,ts,tsx}" and "*.{html,json}"),
leaving other oxfmt-supported file types unhandled; update the package.json
lint-staged entries to add a catch-all oxfmt entry (e.g., a glob like "*" or
"**/*") so oxfmt runs on any staged file type it supports alongside the existing
specific patterns, ensuring the oxfmt task name ("oxfmt") in the lint-staged
object is used for the new catch-all entry and preserving the existing "yarn
lint:js:cmd" associations for the specific globs.
code/core/scripts/generate-source-files.ts (1)

69-77: Verify that these format() calls still honor the repo formatter config.

The old explicit config plumbing is gone, and these generators now rely on bare format(...) calls. Oxfmt’s docs only describe automatic .oxfmtrc.json discovery for the CLI, while the Node API example configures format() via explicit options, so please confirm these outputs still pick up the repo settings; otherwise the generated files will churn against yarn lint:fmt. (oxc.rs)

Also applies to: 105-118, 167-178

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

In `@code/core/scripts/generate-source-files.ts` around lines 69 - 77, The
generators currently call format(...) without loading the repository's oxfmt
config, which can cause churn; change each bare format(...) call (the ones
producing versions.ts and the other blocks around lines 105-118 and 167-178) to
first resolve the repo formatter config (using oxfmt’s Node API e.g., a
load/findConfig or resolveConfig call) and pass that config into format(...) as
options (with a sensible fallback if no config is found), so the formatted
output honors the repo .oxfmtrc.json before writing with writeFile(destination,
formatted).
🤖 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/package.json`:
- Around line 28-30: The package.json scripts currently run oxfmt in write mode
and omit the required lint:other script (ci expects yarn lint:other), so change
the scripts to make formatting validation check-only: update "lint:fmt" to run
"oxfmt --check" and add a new "lint:other" script that runs the remaining
validators used by CI (e.g., same commands as "lint" minus write-mode
formatting), ensuring "lint" composes "lint:js", "lint:ejs" and the new
"lint:other" so CI's yarn lint:other succeeds and oxfmt no longer mutates files
during CI.

---

Nitpick comments:
In `@AGENTS.md`:
- Line 237: The docs currently show only the global command "cd code && oxfmt";
update AGENTS.md to document file-specific usage by adding examples and patterns
(e.g., "oxfmt src/file.ts" and "oxfmt '**/*.{ts,tsx}'") and a short note about
quoting/globbing for shells so contributors can run oxfmt against a single
changed file or a glob of files instead of the whole directory.

In `@code/core/scripts/generate-source-files.ts`:
- Around line 69-77: The generators currently call format(...) without loading
the repository's oxfmt config, which can cause churn; change each bare
format(...) call (the ones producing versions.ts and the other blocks around
lines 105-118 and 167-178) to first resolve the repo formatter config (using
oxfmt’s Node API e.g., a load/findConfig or resolveConfig call) and pass that
config into format(...) as options (with a sensible fallback if no config is
found), so the formatted output honors the repo .oxfmtrc.json before writing
with writeFile(destination, formatted).

In `@code/package.json`:
- Around line 46-53: The lint-staged config currently limits oxfmt to two glob
patterns ("*.{js,jsx,mjs,ts,tsx}" and "*.{html,json}"), leaving other
oxfmt-supported file types unhandled; update the package.json lint-staged
entries to add a catch-all oxfmt entry (e.g., a glob like "*" or "**/*") so
oxfmt runs on any staged file type it supports alongside the existing specific
patterns, ensuring the oxfmt task name ("oxfmt") in the lint-staged object is
used for the new catch-all entry and preserving the existing "yarn lint:js:cmd"
associations for the specific globs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 781bf779-1421-4074-b66a-16a684e17604

📥 Commits

Reviewing files that changed from the base of the PR and between f1d7dea and 10a1e1b.

⛔ Files ignored due to path filters (2)
  • code/lib/codemod/src/transforms/__tests__/__snapshots__/upgrade-deprecated-types.test.ts.snap is excluded by !**/*.snap
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (41)
  • .github/workflows/fork-checks.yml
  • .oxfmtrc.json
  • .serena/memories/project_overview.md
  • .vscode/settings.json
  • AGENTS.md
  • CONTRIBUTING.md
  • code/.oxfmtrc.json
  • code/.prettierignore
  • code/addons/docs/docs/frameworks/WEB_COMPONENTS.md
  • code/core/scripts/generate-source-files.ts
  • code/core/src/common/utils/__tests-formatter__/withPrettierConfig/.prettierrc
  • code/core/src/csf/story.ts
  • code/core/src/manager-api/modules/stories.ts
  • code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.test.ts
  • code/frameworks/angular/src/client/angular-beta/StorybookModule.test.ts
  • code/frameworks/angular/src/client/csf-factories.test.ts
  • code/frameworks/angular/src/client/decorateStory.test.ts
  • code/frameworks/web-components-vite/template/cli/js/Header.js
  • code/frameworks/web-components-vite/template/cli/ts/Header.ts
  • code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
  • code/lib/codemod/src/transforms/csf-2-to-3.ts
  • code/lib/codemod/src/transforms/upgrade-deprecated-types.ts
  • code/lib/eslint-plugin/scripts/update-lib-configs.ts
  • code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts
  • code/lib/eslint-plugin/scripts/update-lib-index.ts
  • code/lib/eslint-plugin/src/index.ts
  • code/package.json
  • code/prettier.config.mjs
  • code/renderers/web-components/src/csf-factories.test.ts
  • code/renderers/web-components/src/docs/__testfixtures__/lit-element-demo-card/input.js
  • code/renderers/web-components/template/cli/js/Header.js
  • code/renderers/web-components/template/cli/ts/Header.ts
  • code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js
  • prettier.config.mjs
  • scripts/.eslintrc.cjs
  • scripts/build/utils/dts-process.ts
  • scripts/create-nx-sandbox-projects.ts
  • scripts/package.json
  • scripts/prettier.config.js
  • scripts/utils/tools-esm.ts
  • scripts/utils/tools.ts
💤 Files with no reviewable changes (7)
  • scripts/utils/tools.ts
  • scripts/.eslintrc.cjs
  • code/prettier.config.mjs
  • scripts/prettier.config.js
  • prettier.config.mjs
  • code/.prettierignore
  • scripts/utils/tools-esm.ts

Comment thread code/package.json Outdated
@huang-julien huang-julien marked this pull request as ready for review March 17, 2026 16:22
@huang-julien huang-julien self-assigned this Mar 17, 2026
@huang-julien huang-julien marked this pull request as draft March 17, 2026 16:37
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.

🧹 Nitpick comments (1)
code/core/src/core-server/utils/get-new-story-file.test.ts (1)

169-169: Avoid quote-style-coupled assertion here.

This assertion is brittle to formatter/config changes. Match the import semantically so behavior is tested regardless of ' vs " output.

Proposed change
-    expect(storyFileContent).toContain('import { fn } from "storybook/test";');
+    expect(storyFileContent).toMatch(
+      /import\s+\{\s*fn\s*\}\s+from\s+['"]storybook\/test['"];/
+    );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code/core/src/core-server/utils/get-new-story-file.test.ts` at line 169, The
test's assertion is brittle because it expects a specific quote style; update
the assertion on storyFileContent (the expect(...).toContain call) to match the
import semantically using a quote-agnostic regex or pattern match (e.g., use
toMatch with a regex that allows either ' or " and tolerates whitespace) so the
test verifies the import of fn from storybook/test regardless of formatter quote
changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@code/core/src/core-server/utils/get-new-story-file.test.ts`:
- Line 169: The test's assertion is brittle because it expects a specific quote
style; update the assertion on storyFileContent (the expect(...).toContain call)
to match the import semantically using a quote-agnostic regex or pattern match
(e.g., use toMatch with a regex that allows either ' or " and tolerates
whitespace) so the test verifies the import of fn from storybook/test regardless
of formatter quote changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0abc445f-04e5-46a4-8b57-dd035e16be77

📥 Commits

Reviewing files that changed from the base of the PR and between 711c0e8 and e94d9b0.

📒 Files selected for processing (1)
  • code/core/src/core-server/utils/get-new-story-file.test.ts

@huang-julien huang-julien marked this pull request as ready for review March 18, 2026 09:16
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
code/lib/cli-storybook/src/automigrate/fixes/migrate-addon-console.test.ts (1)

18-25: ⚠️ Potential issue | 🟠 Major

Add spy: true option and move mock implementation to beforeEach; fix return type to Promise.

The formatFileContent mock at line 24 has multiple issues:

  1. Missing spy: true option in vi.mock() call
  2. Mock behavior is inline in the module factory instead of in a beforeEach block
  3. Critical: The real formatFileContent is async (returns Promise<string>), but the mock returns a synchronous string directly

Apply these fixes:

  • Add spy: true to the vi.mock() call
  • Move all mock implementations to a beforeEach block using vi.mocked()
  • Wrap the mock return value in a Promise to match the async signature

Per coding guidelines: "Use vi.mock() with the spy: true option for all package and file mocks in Vitest tests", "Implement mock behaviors in beforeEach blocks in Vitest tests", "Each mock implementation should return a Promise for async functions in Vitest", and "Avoid mock implementations outside of beforeEach blocks in Vitest tests".

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

In `@code/lib/cli-storybook/src/automigrate/fixes/migrate-addon-console.test.ts`
around lines 18 - 25, Add the missing spy: true option to the vi.mock(...) call
and remove inline implementations from the module factory; instead, in a
beforeEach block use vi.mocked(getAddonNames), vi.mocked(removeAddon) and
vi.mocked(formatFileContent) to set their mock implementations, ensuring
formatFileContent returns a Promise<string> (e.g., Promise.resolve(content)) to
match the real async signature; keep the module factory only returning the
spread original exports with jest spies created by vi.mock(..., { spy: true })
and configure behavior in beforeEach.
🧹 Nitpick comments (2)
code/core/scripts/generate-source-files.ts (1)

69-79: Extract a shared formatAndWrite helper to remove repetition.

The same format(...) + writeFile(...) sequence appears three times; a helper would centralize behavior and reduce drift risk.

♻️ Proposed refactor
+async function formatAndWrite(
+  filename: string,
+  destination: string,
+  source: string
+): Promise<void> {
+  const { code } = await format(filename, source, { singleQuote: true });
+  await writeFile(destination, code);
+}
+
 async function generateVersionsFile(): Promise<void> {
   const destination = join(CORE_ROOT_DIR, 'src', 'common', 'versions.ts');
@@
-  const { code: formatted } = await format(
-    'versions.ts',
-    dedent`
-      // auto generated file, do not edit
-      export default ${versions};
-    `,
-    { singleQuote: true }
-  );
-
-  await writeFile(destination, formatted);
+  await formatAndWrite(
+    'versions.ts',
+    destination,
+    dedent`
+      // auto generated file, do not edit
+      export default ${versions};
+    `
+  );
 }
@@
-  const { code: formatted } = await format(
-    'frameworks.ts',
-    dedent`
-      // auto generated file, do not edit
-      export enum SupportedFramework {
-        // CORE
-        ${coreFrameworks},
-        // COMMUNITY
-        ${communityFrameworks}
-      }
-    `,
-    { singleQuote: true }
-  );
-
-  await writeFile(destination, formatted);
+  await formatAndWrite(
+    'frameworks.ts',
+    destination,
+    dedent`
+      // auto generated file, do not edit
+      export enum SupportedFramework {
+        // CORE
+        ${coreFrameworks},
+        // COMMUNITY
+        ${communityFrameworks}
+      }
+    `
+  );
 }
@@
-  const { code: formatted } = await format(
-    'exports.ts',
-    dedent`
-      // this file is generated by sourcefiles.ts
-      // this is done to prevent runtime dependencies from making it's way into the build/start script of the manager
-      // the manager builder needs to know which dependencies are 'globalized' in the ui
-
-      export default ${JSON.stringify(data)} as const;
-    `,
-    { singleQuote: true }
-  );
-
-  await writeFile(destination, formatted);
+  await formatAndWrite(
+    'exports.ts',
+    destination,
+    dedent`
+      // this file is generated by sourcefiles.ts
+      // this is done to prevent runtime dependencies from making it's way into the build/start script of the manager
+      // the manager builder needs to know which dependencies are 'globalized' in the ui
+
+      export default ${JSON.stringify(data)} as const;
+    `
+  );
 }

Also applies to: 106-121, 169-182

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

In `@code/core/scripts/generate-source-files.ts` around lines 69 - 79, Extract a
small helper named formatAndWrite (or similar) that takes (filename: string,
source: string) and encapsulates the await format(...) call and subsequent await
writeFile(destination, formatted) logic used in this file; replace the three
duplicated blocks (the one that builds 'versions.ts' plus the other occurrences
around lines 106-121 and 169-182) to call formatAndWrite('versions.ts',
dedent`...`) (and the other filenames/contents) so formatting and file writing
are centralized, returning the formatted result or void as needed and preserving
the existing options ({ singleQuote: true }).
code/.oxfmtrc.json (1)

10-11: Consider removing *.md / *.mdx from ignores once rollout is stable.

Keeping docs ignored long-term will likely create formatting drift between code and docs; a tracked follow-up would help avoid that.

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

In `@code/.oxfmtrc.json` around lines 10 - 11, The .oxfmtrc.json currently ignores
"*.md" and "*.mdx" which will let docs diverge from code formatting; remove the
"*.md" and "*.mdx" entries from the ignore list in .oxfmtrc.json so docs are
formatted by the tool, and if you can’t flip this immediately open a tracked
follow-up (issue/PR) to re-enable docs formatting once the rollout is stable so
this change isn’t lost.
🤖 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/lib/cli-storybook/src/codemod/helpers/config-to-csf-factory.test.ts`:
- Around line 9-11: The test currently sets a mock implementation at module
scope via vi.mocked(formatFileContent).mockImplementation(...); move that mock
behavior into a beforeEach block so the implementation is configured per-test
(e.g., add beforeEach(() =>
vi.mocked(formatFileContent).mockImplementation(async (_path, content) =>
content));) and ensure mocks are cleared between tests (use vi.resetAllMocks()
or vi.restoreAllMocks() in afterEach) so formatFileContent's mock does not leak
across tests; keep the vi.mock('storybook/internal/common', { spy: true }) at
module scope but relocate the mockImplementation for formatFileContent to
beforeEach and clean up in afterEach.

---

Outside diff comments:
In `@code/lib/cli-storybook/src/automigrate/fixes/migrate-addon-console.test.ts`:
- Around line 18-25: Add the missing spy: true option to the vi.mock(...) call
and remove inline implementations from the module factory; instead, in a
beforeEach block use vi.mocked(getAddonNames), vi.mocked(removeAddon) and
vi.mocked(formatFileContent) to set their mock implementations, ensuring
formatFileContent returns a Promise<string> (e.g., Promise.resolve(content)) to
match the real async signature; keep the module factory only returning the
spread original exports with jest spies created by vi.mock(..., { spy: true })
and configure behavior in beforeEach.

---

Nitpick comments:
In `@code/.oxfmtrc.json`:
- Around line 10-11: The .oxfmtrc.json currently ignores "*.md" and "*.mdx"
which will let docs diverge from code formatting; remove the "*.md" and "*.mdx"
entries from the ignore list in .oxfmtrc.json so docs are formatted by the tool,
and if you can’t flip this immediately open a tracked follow-up (issue/PR) to
re-enable docs formatting once the rollout is stable so this change isn’t lost.

In `@code/core/scripts/generate-source-files.ts`:
- Around line 69-79: Extract a small helper named formatAndWrite (or similar)
that takes (filename: string, source: string) and encapsulates the await
format(...) call and subsequent await writeFile(destination, formatted) logic
used in this file; replace the three duplicated blocks (the one that builds
'versions.ts' plus the other occurrences around lines 106-121 and 169-182) to
call formatAndWrite('versions.ts', dedent`...`) (and the other
filenames/contents) so formatting and file writing are centralized, returning
the formatted result or void as needed and preserving the existing options ({
singleQuote: true }).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8c47f1bc-a755-4026-81c4-9f7d9e3ccde6

📥 Commits

Reviewing files that changed from the base of the PR and between e94d9b0 and dc2fe6b.

⛔ Files ignored due to path filters (1)
  • code/lib/codemod/src/transforms/__tests__/__snapshots__/upgrade-deprecated-types.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (25)
  • code/.oxfmtrc.json
  • code/core/scripts/generate-source-files.ts
  • code/core/src/core-server/utils/get-new-story-file.test.ts
  • code/lib/cli-storybook/src/automigrate/fixes/migrate-addon-console.test.ts
  • code/lib/cli-storybook/src/codemod/helpers/config-to-csf-factory.test.ts
  • code/lib/cli-storybook/src/codemod/helpers/story-to-csf-factory.test.ts
  • code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
  • code/lib/eslint-plugin/docs/rules/await-interactions.md
  • code/lib/eslint-plugin/docs/rules/csf-component.md
  • code/lib/eslint-plugin/docs/rules/default-exports.md
  • code/lib/eslint-plugin/docs/rules/hierarchy-separator.md
  • code/lib/eslint-plugin/docs/rules/meta-inline-properties.md
  • code/lib/eslint-plugin/docs/rules/meta-satisfies-type.md
  • code/lib/eslint-plugin/docs/rules/no-redundant-story-name.md
  • code/lib/eslint-plugin/docs/rules/no-renderer-packages.md
  • code/lib/eslint-plugin/docs/rules/no-stories-of.md
  • code/lib/eslint-plugin/docs/rules/no-title-property-in-meta.md
  • code/lib/eslint-plugin/docs/rules/no-uninstalled-addons.md
  • code/lib/eslint-plugin/docs/rules/story-exports.md
  • code/lib/eslint-plugin/docs/rules/use-storybook-expect.md
  • code/lib/eslint-plugin/docs/rules/use-storybook-testing-library.md
  • code/lib/eslint-plugin/scripts/update-lib-configs.ts
  • code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts
  • code/lib/eslint-plugin/scripts/update-lib-index.ts
  • docs/configure/integration/eslint-plugin.mdx
✅ Files skipped from review due to trivial changes (11)
  • code/lib/eslint-plugin/docs/rules/use-storybook-expect.md
  • code/lib/eslint-plugin/docs/rules/no-uninstalled-addons.md
  • code/lib/eslint-plugin/docs/rules/no-renderer-packages.md
  • code/lib/eslint-plugin/docs/rules/use-storybook-testing-library.md
  • code/lib/eslint-plugin/docs/rules/no-title-property-in-meta.md
  • code/lib/eslint-plugin/docs/rules/no-stories-of.md
  • code/lib/eslint-plugin/docs/rules/csf-component.md
  • code/lib/eslint-plugin/docs/rules/meta-satisfies-type.md
  • code/lib/cli-storybook/src/codemod/helpers/story-to-csf-factory.test.ts
  • code/lib/eslint-plugin/docs/rules/story-exports.md
  • code/lib/eslint-plugin/docs/rules/hierarchy-separator.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • code/lib/eslint-plugin/scripts/update-lib-configs.ts
  • code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts
  • code/core/src/core-server/utils/get-new-story-file.test.ts

…ry.test.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@huang-julien huang-julien changed the title Build: move prettier to oxfmt Build: Move prettier to oxfmt Mar 18, 2026
Comment thread scripts/package.json Outdated
Comment thread code/package.json
Comment thread code/core/src/core-server/utils/get-new-story-file.test.ts Outdated
Comment thread code/core/src/core-server/utils/get-new-story-file.test.ts Outdated
Comment thread code/core/src/manager-api/modules/stories.ts
Comment thread code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts Outdated
Comment thread code/lib/eslint-plugin/docs/rules/await-interactions.md Outdated
@huang-julien huang-julien marked this pull request as draft March 18, 2026 11:18
@huang-julien huang-julien marked this pull request as ready for review March 18, 2026 16:14
@huang-julien huang-julien merged commit 15edac0 into next Mar 19, 2026
126 checks passed
@huang-julien huang-julien deleted the chore/oxfmt branch March 19, 2026 13:48
@github-actions github-actions Bot mentioned this pull request Mar 19, 2026
17 tasks
@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
@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 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.

3 participants