-
Notifications
You must be signed in to change notification settings - Fork 108
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
Possibility of removing the prettier parser arguments, or add the ability to configure your own #175
Comments
Commit 6bcd9a5 should fix JSON5 for prettier. Should be in MELPA in a couple hours. Does it work? |
JSON5 is detected when you use |
If there are other JSON5 modes for Emacs (e.g. in web-mode), please let me know and I'll add them. |
The main issue is that prettier by default formats emacs-format-all-the-code/format-all.el Line 1009 in 6200b91
In essence, if you don't add the workaround it means that for json files, running prettier in the command line and running prettier in the editor gives a slightly different result. Though, it's not a major problem, ideally this line should not be needed as you can configure the parser options with prettier itself. I'm just unsure on the impact, because it does mean if people haven't properly configured prettier parser options in the |
Does prettier use |
From what I tested it seems to be yes, but I think that's beside my point. We shouldn't be overriding the parser options to begin with as you configure the parser options using the |
Good point. But format-all should still choose a formatter when there's no rc file, or the rc file does not specify a formatter. Would https://prettier.io/docs/en/cli.html#--config-precedence
|
I had something written here, that I don't agree with anymore. EDIT: The thing is that prettier already guesses the correct parser for you, it's not something you usually configure yourself. So even if you don't have an rc file, prettier will still work and correctly format all the files it knows how to format (if you run them through prettier). Basically, I'm suggesting this: #182 |
Let `prettier` itself select the right parser for named files. It can look at the file name extension to figure out which one to pick.
Please try out the fix I just pushed to the |
My apologies for the extreme late reply. I finally got around to testing your branch. Looks like it's working fine! :) |
Let `prettier` itself select the right parser for named files. It can look at the file name extension to figure out which one to pick.
No problem. Glad to hear it works. I merged it to master. Let me know if any problems come up. For reference, that's commit 828280e. |
@lassik Broken change here, 828280e cause another problem. I agree we should let prettier select parser automatically, but if it fails, we need to add arguments by langugae-id |
I'm currently running into an issue with prettier formatting the package.json using the
json5
parser, while Emacs formats it with thejson
parser. The CLI arguments take precedence over the.prettierrc
overrides, so even when I try addingjson5
as the override for all json files, it doesn't respect due the CLI parser arguments.Thus, I'm wondering why the prettier formatter depends on the parser arguments, see:
emacs-format-all-the-code/format-all.el
Line 1009 in 6200b91
Is there some special cases I'm currently unaware of?
According to the prettier documentation, choosing the correct parser is supposed to be handled by prettier itself. If you really need to change some parser, there's possibility to override using the
.prettierrc
, for example:The text was updated successfully, but these errors were encountered: