Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix parser inference - #15927

#15927
Merged
fisker merged 8 commits into
prettier:mainprettier/prettier:mainfrom
fisker:jsoncfisker/prettier:jsoncCopy head branch name to clipboard
Jan 16, 2024
Merged

Fix parser inference#15927
fisker merged 8 commits into
prettier:mainprettier/prettier:mainfrom
fisker:jsoncfisker/prettier:jsoncCopy head branch name to clipboard

Conversation

@fisker

@fisker fisker commented Jan 15, 2024

Copy link
Copy Markdown
Member

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
@fisker
fisker deleted the jsonc branch January 16, 2024 02:34
@HolgerJeromin

Copy link
Copy Markdown
Contributor

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

@henrikvolmer

Copy link
Copy Markdown

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

#15946

Please revert.

@erikbrgn

Copy link
Copy Markdown

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

jorgecasar commented Jan 24, 2024

Copy link
Copy Markdown

@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.

7 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.