-
-
Notifications
You must be signed in to change notification settings - Fork 458
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
Prettier VS Code 3.0 #958
Comments
¢¢: Totally agree that prettier should be installed locally in repos with web apps. However, this is not necessarily true for other languages. For example, if you want to use Prettier with Elm, you'd probably prefer a global instance of
Do you mean flagged as deprecated (still working) or totally removed? Overall, I fully support the idea that the VSCode extension is just s thin wrapper that calls Prettier CLI for us. Atom Extension for Prettier made a similar shift some time ago. |
I think there's an extra "not" in there - the plan is to require a local install of prettier, linters and their integrations :) One potential thing to be aware of: At Shopify we use eslint-plugin-prettier to format our code as part of running eslint. When running
That would mean anybody with non-node etc projects will run into problems with shared dependencies. Consider having local checkouts of
I'd guess existing but undesired behaviour (e.g. defining prettier config within vscode) would be deprecated in v2.x releases then removed v3.0. |
I'm aware of this limitation. However, I still see benefits in using global prettier and prettier plugins in certain scenarios. One concrete example would be education: a student that works on their own (non-js) code uses the same instance of |
I was thinking a bit about this. I think what I would like to do is mark them as deprecated and then prompt a warning for people who are using them and link to a doc. We would not use the settings for prettier, but this would make it so people can migrate and understand what is going on. Then in say version 4.0 we would remove them entirely. |
Yes. Fixed. :) |
Anything community can help you with? I'm interested in upgrading |
Started working on this in a branch: https://github.com/prettier/prettier-vscode/tree/3.0 |
These are really good changes. In prettier-atom we've already switched to using We ripped out the ability to configure their prettier options via the package a while ago. You will have some people complain at first about how they can no longer configure everything through the package and how it was so easy before, but it's not your fault, it's the direction that Prettier went (and IMO, the correct direction) from a simple couple of options to something that is ever-growing and more enhanceable with plugins. It's just plain not compatible with the in-editor settings anymore (and we had the same problem where we were constantly having to play catchup with new options Prettier was adding). If they still want a default/global configuration, they can just put a prettierrc in their root folder. Also, we've had that same issue with prettier-eslint, and honestly I'm seriously considering pulling it out although some users are really insistent that they still want it. There is a fix for that coming very soon they just have to merge it (they weren't respecting the current working directory). And |
@robwise Awesome, this is really good to hear. Thanks for letting me know! |
The preview version 3.0.0 is now live on the marketplace for anyone who wants to try it. There will be bugs and there are still more breaking changes coming, so I wouldn't use it as your main formatter yet. You can use VS Code insiders and install this extension to keep your main VS Code clean. https://marketplace.visualstudio.com/items?itemName=Prettier.prettier-vscode |
Thanks for sharing @ntotten. FWIW: this solved my linting woes on my project where I'm using eslint 6.5.1 / typescript 3.7.0 beta w/ new experimental features (using the un-merged version of prettier/prettier#6657). |
if i have no configuration and I only want the extension to use the eslint ruleset, will I have to change anything to comply with version 3? will I have to duplicate the eslint ruleset inside |
@YuriScarbaci You shouldn't, however, if you want to publish a github repo of your setup I can use it to validate that things are working as expected. |
sure, this is a basic react repo i created as a demo with only the eslint config i'm currently using in my other projects: https://github.com/YuriScarbaci/react-eslint-bootstrap currently I am not using prettier-vscode anymore due to the feature of reading the ruleset from .eslint not working with the latest eslint versions, but, truth be told, I'm missing the good old prettier extension that was able to format my document in one go instead of having to eslint-fix multiple times. + prettier was formatting the document even if there was an error in the eslint, right now i must first fix the error and then i can eslint-fix format... |
@BPScott I'm getting close to finishing up version 3.0. Would you mind verifying the preview version of 3.0 and see it there are any issues with the shopify setup or if you have any other feedback/issues. You can install the preview version here: https://marketplace.visualstudio.com/items?itemName=Prettier.prettier-vscode |
@ntotten - Since I installed v3, I'm getting this error even though I believe I removed all legacy settings?
The only prettier config I have in my settings is And it seems that eslint/tslint doesn't autofix anything/everything anymore even though I have |
@tleunen the As far as the eslint stuff goes, we still do support the |
Good catch. I forgot I had a workspace settings file in my project 😅 |
Will do, I'll try and squeeze some time in later this week. |
Prettier 1.19.1 is just out! Vital support for TypeScript 3.7 is now available!! I was wondering how long until this gets into Prettier VS Code 3.0? Thanks! If I delete my current version and add the new version from https://marketplace.visualstudio.com/items?itemName=Prettier.prettier-vscode am I OK from now on? That will become the official version, or do I need to monitor it and do something else when it goes stable? |
@BPScott I see that in your referenced issue above you are switching to use eslint for prettier formatting. To clarify, I am not removing the support for linters in this version of the extension, but maybe if the eslint extension is better for that type of integration we should. Let me know what you think. |
Just updated to
Big improvement to use Prettier's own settings rather than VS Code's, that was always a hack. Things feel more cruft free and groovy now... THANKS! |
I think I have a bug, it does not seem able to format JSON with comments. Add this, then you get an error:
|
@David-Else I’ll check into ASAP. Thanks for reporting. |
unsure grunting and huffing. It's complicated and my hand was kinda forced by upstream inaction and the passage of time. In the above linked issue we updated to eslint 6 which is not currently supported by prettier-eslint and while the PR to add eslint 6 support looks trivial prettier-eslint's maintainer hasn't been able to find the time to merge it (and that's totally OK!). I found that trying to format code using In an ideal world I'd want some symmetry between how my js, css and md files are formatted. In the past this was easy - they were all formatted using In a new world I'd also be happy with the removal of linter support as long as there's a consistent story for each of those file types. The Keeping support for linters for the time being would be helpful till I can confirm that's there's a good story for "you want to autoformat your css/scss/etc files using stylelint (which runs prettier as a plugin)." that will allow me to no longer need the An alternative to the endpoint of using multiple plugins for the varying file types we could keep the integration settings and stick with the rule of " Oh and just for clarity: I haven't had a chance to try out v3 package |
@David-Else it is my understanding that this plugin uses the version of prettier that is installed within your own project (and only falling back to its bundled version if that isn't found). You should be able to update your |
Prettier VS Code 3.1 is using the latest prettier:
|
@David-Else I am not able to reproduce the bug with the jsonc settings. If you could open a new issue and provide the full output logs for prettier or share a sample project that would be helpful. Thanks! |
@ntotten I can't find any output logs for prettier since the icon disappeared from the bottom right panel... it was good to know if prettier was working on a particular file, kind of miss that icon. |
@David-Else From the view menu click "Output" then from the dropdown there select "Prettier". I think the icon wasn't really needed after VS Code allowed you to specify the default formatter, but I may add it back if i have some time. |
New versions of the Prettier VSCode plugin (in particular, 3.8) have started to complain about certain out-of-date settings in VSCode config files. Remove the relevant (or rather, now-irrelevant) config option from our workspace. Users may need to manually update their Prettier VSCode extension to continue to format code with Prettier on save. See: - https://github.com/prettier/prettier-vscode/blob/62004a02b4/README.md#user-content-error-messages - prettier/prettier-vscode#958
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Yesterday, I spent some time talking with @BPScott about how he and other developers (at Shopify and other places) use VS Code Prettier with the linters. After our discussion, we believe we have a path forward that will allow continued support for prettier + linters while also reducing the issues with the current implementation. Along with that change, we are proposing a few other changes to this extensions. Below are the main changes proposed for VS Code Prettier 3.0. Please let me know what you think.
No longer ship with linters in the extension
Shipping with the linters in the extension results in a lot of potential version conflicts. For example, we currently include
prettier-eslint
in the extension, however that is not compatible for eslint versions > 5. As a result, many people are installing eslint@6 and seeing this extension break. There isn't really a great way to inform people of those type of conflicts.In order to make it easier for developers to understand when different dependencies are incompatible, we will require you to install prettier, the linters, and the prettier/linter integrations in your local project (
package.json
) in order to use the Prettier VS Code + Linter features.What this means is the linting functionality this extension provides will continue to work, however, in order to set it up you will have to do an NPM install. The benefit of this is if you do an NPM install on incompatible package versions, NPM will tell you and users can better understand the error.
Encourage use of local prettier
We believe that when using prettier in your IDE you should always have a scriptable way of executing prettier as well. The Prettier VS Code integration is really a convenience, but it should not be used on its own. Every project using prettier should support running prettier through a CLI (outside of the IDE) and ideally use something like precommit hooks to ensure that all code checked into source control will be formatted the same.
We will continue to ship prettier with the extension so that users have an easy onboarding experience and so they can use prettier for things like formatting JSON outside of a project, but we will change the documentation to encourage that everyone always installs prettier locally in their projects. We may also provide warnings in VS Code in certain circumstances if you are using the built-in version of prettier.
Reduce Duplicate Configuration
Today, you can configure prettier in VS Code settings, using the
.editorconfig
file, and using the Prettier configuration files. Additionally, the extension tries to actually merge these version configurations together and applies them in a certain priority order. We have found that this results in a lot of confusion. For example, if you set the global setting to use tabs, but then you clone a project that already has a prettierrc or editorconfig file that overrides this setting, you may not understand where the setting is coming from.Supporting all of these types of configurations is also a maintenance issue. Every time prettier changes a setting, people ask us to add it to VS Code settings. Additionally, we get requests to add other settings like ESLint, etc.
As such, version 3.0.0 of this project will ONLY support settings through the default prettier configurations. This includes the
.editorconfig
and prettier configuration file. All prettier duplicate VS Code settings will be deprecated.Work
getFileInfo
to resolve which formatter to use as default instead of VS Code. This will resolve many issues such as not formatting graphql, etc.getFileInfo
to determine if a file is ignored.prettierrc
from existing configPrettier: Initialize
command to add.prettierrc
file (or whatever format the user wants)Release Plan
Because this is going to release as several beta versions and is going to be a large breaking change, I am going to release this version as a new publish (prettier). This is also something we have wanted to do anyway for a while to make it more official.
Initially, I will maintain both versions 2.x on the current publisher and version 3.x on the new publisher.
Once version 3.0 is stable and sufficiently tested, I will publish a new version of 2.x that will simply depend on the new extension - thus moving everyone to the new extension.
The text was updated successfully, but these errors were encountered: