Skip to content

#0: Don't try to load prettier config if formatOnSave is false #2284

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

justinjxzhang
Copy link

@justinjxzhang justinjxzhang commented May 21, 2025

PR details

I noticed while trying to retrieve query I was getting an error around prettier configurations, even though I had formatOnSave set to false.

While the retrieval still continued, the program exits with code 1 (due to the Util.logger.error function calling Util.signalFatalError which sets process.exitCode = 1) so this caused needing a bit of a workaround to get it working programatically inside another application.

What changes did you make? (Give an overview)

If the formatOnSave option is false then the initPrettier function will early exit without trying to find the prettierrc config.

Further details (optional)

I tried to add tests around the initPrettier function but couldn't see a straightforward way. I wanted to mock the Util module in order to check that Util.logger.error wasn't called, but it appears that module mocking is only supported as an experimental feature in node:test at the moment. I didn't want to go too far overboard with re-structuring things (especially in a first contribution), and given the tests appear to primarily be around the types or an end-to-end process, I thought it might squeak by.

...

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • test scripts updated
  • Wiki updated (if applicable)

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