-
-
Notifications
You must be signed in to change notification settings - Fork 459
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
Settings in VSCode's settings.json
didn't work when there is a .editorconfig
in the project
#1079
Comments
This is by design. The VSCode settings are fallback only. If prettier finds a config file (editorconfig or prettier config) then only those config will be used. The recommendation is to set a prettier configuration file for the project. |
Thanks for you kind reply.
Let’s take the semicolon for example; I set “prettier.semi : false” in my VSCode settings.
And I just wrote these in my editorconfig :
“
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
”
In my opinion, it should follow the VSCode’settings: no semicolon at the end of the sentence, but actually, it follows the prettier’s detault setting : auto add semicolon ;
Do I have to set a prettier configuration for every project just for no semicolon ?
I will noted and many thanks!
发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用
发件人: Nathan Totten<mailto:[email protected]>
发送时间: 2019年11月20日 20:37
收件人: prettier/prettier-vscode<mailto:[email protected]>
抄送: Henry-WHY<mailto:[email protected]>; Author<mailto:[email protected]>
主题: Re: [prettier/prettier-vscode] Settings in VSCode's `settings.json` didn't work when there is a `.editorconfig` in the project (#1079)
This is by design. The VSCode settings are fallback only. If prettier finds a config file (editorconfig or prettier config) then only those config will be used. The recommendation is to set a prettier configuration file for the project.
―
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#1079?email_source=notifications&email_token=AJTKPVQEETCPAQEYKJPWZJTQUUVQDA5CNFSM4JPPNAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEER2XUA#issuecomment-555985872>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJTKPVR3JA6HTUZDN675TQDQUUVQDANCNFSM4JPPNAMA>.
|
Yeah, that's what you would have to do. I think this is the correct behavior because you also should be able to run prettier in a project through the CLI and if we included VS Code settings running through the vscode extension and the cli would produce different results. The VS Code settings are really only intended to be used in non-projects. Like if you open a JSON file and want to format it. The recommendation is to ALWAYS include a |
@ntotten Is it really smart though? For example I see here editorconfig/editorconfig#331 Achieing all options like prettier.semi not possible if that file exist :/ Also Angular creates .editorconfig by default for new projects. |
I'm not a fan of this change because, for all of my Angular projects that had my linting + formatting working a few days ago, I now need to make changes for all of them to be usable. This seems like a rather large update to prettier that suddenly had me not being able to write code as my formatting and linting were all messed up which muddies git commits with "changes" just due to format. Instead of dealing with this, I just reverted back to 3.7.0 and everything worked as expected. |
Similarly, I mostly use prettier for formatting the README markdown in my projects. To enable line wrapping I enable a single option This change requires me to add a prettierrc config file to every one of my projects just to be able to have prettier wrap long lines in my README which is rather annoying. I can understand disabling the VSCode settings when a .prettierrc file is found but please don't disable VSCode options when a .editorconfig file is found. Another option is to merge VSCode prettier options that cannot be expressed in editorconfig instead of discarding them. EDIT: I found the option to disable use of .editorconfig but would still like the prettier specific VSCode options to be merged with the editorconfig inferred options if possible. |
I know some people are passionate about this behavior, but there are 500k daily users of this extension and for the vast majority, this behavior is correct. I might consider adding a setting to merge the editor config and VSCode settings, but that will require changes to prettier itself as right now there is no way to know where prettier resolved the setting from. To be very honest though, I don’t really put much weight in the argument that you don’t want to add a prettier config file to your project because 1) it takes 15 seconds and 2) it is a best practice when using prettier. As I explained before, merging by default has a lot of undesirable consequences that are far more important than a simple convenience of not adding a config file. |
Environments:
Steps to reproduce:
Settings should be read from
But as long as there's a
.editorconfig
in the project without.prettierrc
, Settings which have been written in the VSCode'ssettings.json
are no longer valid, even if they are not mentioned in the.editorconfig
Expected behavior:
Read the settings which are not mentioned in the
.editorconfig
from VSCode'ssettings.json
Actual behavior:
Read the settings which are not mentioned in the
.editorconfig
from prettier's default settingsThe text was updated successfully, but these errors were encountered: