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

Fix parser inference #15927

Merged
merged 8 commits into from Jan 16, 2024
Merged

Fix parser inference #15927

merged 8 commits into from Jan 16, 2024

Conversation

fisker
Copy link
Sponsor Member

@fisker fisker commented Jan 15, 2024

Description

Should infer parser by filenames first, then by extensions.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker fisker marked this pull request as ready for review January 15, 2024 13:19
@fisker fisker merged commit c566c9d into prettier:main Jan 16, 2024
25 of 26 checks passed
@fisker fisker deleted the jsonc branch January 16, 2024 02:34
@HolgerJeromin
Copy link
Contributor

Just as a reference:
This makes tools like jsonlint (linting *.json in my project) and visual studio intellisense unhappy. :-(

@henrikvolmer
Copy link

Does not work with .eslintrc.json files (and maybe many other files, which aren't support jsonc).

#15946

Please revert.

@erikbrgn
Copy link

Absolutely breaksjest if you have trailing commas enabled in prettier and import your tsconfig.json in your jest config. The tsconfig can no longer be parsed because of that. I guess a temporary solution would be to ignore formatting the tsconfig.

@gaby

This comment was marked as spam.

@jorgecasar
Copy link

jorgecasar commented Jan 24, 2024

@fisker @sosukesuzuki

This breaks many JSONs. Changing the parser inference for JSON files from json to jsonc and adding trailing commas to jsonc files breaks with JSON specs that doesn't support trailing commas neither comments. Then is an error parsing json with ´jsonc` parser.

Please rollback to parse JSON with json and later discus about add or remove trailing commas in jsonc parser.

And in the other hands this is not a fix, it's a major change. It's broken all my pipelines.

@prettier prettier locked as resolved and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants