发布

  • feat(devkit): add NX_SKIP_FORMAT environment variable to skip Prettier formatting (#34336)

    frostbyte_neo 发布于 2026-02-18 14:56:43 +00:00

    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.

    下载附件