Skip to content

🐛 Bug Report: backstage-repo-tools api-reports fails to format generated api report files when using Prettier v3 #27559

@mtlewis

Description

@mtlewis

📜 Description

Prettier is used to format generated API reports. This code relies on the resolveConfig.sync method in Prettier, which was removed in v3. This means the code hits the catch block and silently fails.

Note that even if we move away from using this method, the format method itself in prettier has also moved to be async, so we'll likely need a deeper refactoring here if we want to support Prettier v3. It's not clear how we'd actually go about that though, since the curretn approach relies on patching a synchronous method. Perhaps one solution here is a feature request to api-extractor to add support for supplying a custom formatter.

👍 Expected behavior

  • API report generation should succeed with both prettier v2 and v3
  • When formatting fails, we should log an error to make debugging easier

👎 Actual Behavior with Screenshots

Report generation succeeds but files are not formatted.

👟 Reproduction steps

  • Update to prettier v3
  • Generate api-reports in any Backstage codebase
  • Observe that the resulting files are not formatted.

📃 Provide the context for the Bug.

No response

🖥️ Your Environment

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions