Skip to content

Conversation

@baer
Copy link

@baer baer commented Feb 4, 2026

Current Behavior

When running generators or migrations, Nx automatically skips Prettier formatting if no root Prettier config is detected (added in #30426). However, there's no way to explicitly skip Prettier formatting when a config IS present but the user wants to bypass it for specific operations.

This can be needed when:

  • When running something like Oxfmt that may treat prettier slightly differently, even with the same config (this is the main thing I ran into)
  • Running migrations where Prettier reformatting causes unintended side effects (e.g., breaking eslint-disable comments)
  • Temporarily disabling formatting for debugging purposes
  • Using a formatter that coexists with Prettier in the workspace but should take precedence for certain files

Expected Behavior

Users can set NX_SKIP_FORMAT=true to explicitly skip Prettier formatting in generators and migrations, regardless of whether Prettier is configured. TSConfig path sorting (controlled by sortRootTsconfigPaths or NX_FORMAT_SORT_TSCONFIG_PATHS) continues to work independently.

NX_SKIP_FORMAT=true nx migrate --run-migrations
NX_SKIP_FORMAT=true nx g @nx/react:app my-app

Related Issue(s)

Related to #30403 and #30426. This enhancement adds explicit user control for cases where auto-detection of Prettier configuration isn't sufficient.

…r formatting

Add support for skipping Prettier formatting in generators and migrations
via the `NX_SKIP_FORMAT` environment variable. This is useful for
repositories that:

- Use alternative formatters like Biome, dprint, or oxfmt
- Have custom formatting requirements that conflict with Prettier defaults
- Experience issues where Prettier reformatting breaks eslint-disable comments

When `NX_SKIP_FORMAT=true`, the `formatFiles()` function and related
formatting utilities will skip Prettier formatting but will still perform
tsconfig path sorting if enabled via `sortRootTsconfigPaths` option or
`NX_FORMAT_SORT_TSCONFIG_PATHS` environment variable.

Usage:
  NX_SKIP_FORMAT=true nx migrate --run-migrations
  NX_SKIP_FORMAT=true nx g @nx/react:app my-app

Also updates `formatChangedFilesWithPrettierIfAvailable` and
`formatFilesWithPrettierIfAvailable` in the nx package to respect
this environment variable.

Related: nrwl#30403, nrwl#30426
@baer baer requested review from a team as code owners February 4, 2026 22:43
@netlify
Copy link

netlify bot commented Feb 4, 2026

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 97b1c24

@netlify
Copy link

netlify bot commented Feb 4, 2026

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 97b1c24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant