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

Unexpected end of JSON input while parsing empty string on empty json config file #15781

Closed
rmehner opened this issue Dec 11, 2023 · 1 comment
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@rmehner
Copy link

rmehner commented Dec 11, 2023

Environments:

  • Prettier Version: 3.1.1
  • Running Prettier via: npm (prettier --write '**/*.{js,ts,json,md}')
  • Runtime: Node v20
  • Operating System: macoS
  • Prettier plugins (if any): none

Steps to reproduce:

Given a file .prettierrc.json that is just empty, run the command: prettier --write '**/*.{js,ts,json,md}'

Expected behavior:

Things don't break :)

Actual behavior:

With Prettier 3.1.1 this will throw with:

[error] JSON Error in /path/to/project/.prettierrc.json:
[error] Unexpected end of JSON input while parsing empty string

The fix is to add {} to .prettierrc.json and things will work just fine. It's a small regression from 3.1.0 to 3.1.1 that I ran into. It's likely related to #15363.

My use case was to have the empty file, so everything is using prettier defaults and VSCode uses the existence of that file to enable prettier within the editor.

Not sure if worth a fix, since my use case might be very much an edge case you don't need to account for, but with this issue here it's at least searchable & solvable for others who run into this :)

@fisker
Copy link
Member

fisker commented Dec 11, 2023

Our docs suggest use {} to make the empty config valid, so let's close this.

https://prettier.io/docs/en/install

@fisker fisker closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2023
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Mar 11, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants