Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
mtlewis opened this issue Nov 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mtlewis
Copy link
Collaborator

mtlewis commented Nov 8, 2024

📜 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

@mtlewis mtlewis added the bug Something isn't working label Nov 8, 2024
@jhaals
Copy link
Member

jhaals commented Nov 11, 2024

Do the api-report look terrible without format or could we perhaps ignore formatting on those files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants