Skip to content

🐛 fix prettier support for mdx with config#2255

Merged
edno merged 2 commits intomainfrom
chore/improve-prettier-support
Jun 25, 2025
Merged

🐛 fix prettier support for mdx with config#2255
edno merged 2 commits intomainfrom
chore/improve-prettier-support

Conversation

@edno
Copy link
Copy Markdown
Member

@edno edno commented Jun 25, 2025

Description

User mdx parser instead of markdown when calling prettier, and add support for local config file.

Checklist

  • My changes follow the contributing guidelines of this project.
  • I have performed a self-review of my code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my changes work.
  • New and existing unit tests pass locally with my changes.

@edno edno linked an issue Jun 25, 2025 that may be closed by this pull request
@edno edno requested a review from Copilot June 25, 2025 16:48

This comment was marked as outdated.

@edno edno requested a review from Copilot June 25, 2025 16:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes prettier support by updating the parser from "markdown" to "mdx" and adding support for reading a local prettier config file.

  • Updated tests in packages/utils/tests/unit/prettier.test.ts to use the "mdx" parser and verify a more informative error message.
  • Modified packages/utils/src/prettier.ts to resolve a local config file and merge options with the parser.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/utils/tests/unit/prettier.test.ts Updated test cases to reflect the change from "markdown" to "mdx" and check for an improved error message.
packages/utils/src/prettier.ts Changed to resolve the local prettier config and updated error logging and parser usage to "mdx".

Comment on lines +42 to +46
const message = `Prettier is not found or not configured. Please install it or disable the "pretty" option.`;
if ("logger" in global && global.logger) {
(global.logger as LoggerType)._log("Prettier is not found");
(global.logger as LoggerType)._log(message);
} else {
global.console.log("Prettier is not found");
global.console.log(message);
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the error message to a shared constant to improve maintainability and ensure consistency between implementation and tests.

Copilot uses AI. Check for mistakes.
expect(consoleSpy).toHaveBeenCalledWith("Prettier is not found");
expect(consoleSpy).toHaveBeenCalledWith(
'Prettier is not found or not configured. Please install it or disable the "pretty" option.',
);
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that error message expectations are updated if the error message is refactored; consider referencing the shared constant from the implementation in tests if feasible.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
61.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@edno edno merged commit 4a9e69b into main Jun 25, 2025
29 of 32 checks passed
@edno edno deleted the chore/improve-prettier-support branch June 25, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Cannot get pretty to work in Docusaurus project

2 participants