-
-
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
Enable only if prettier is installed #199
Comments
There are already some ways to disable the extension. I'm not sure one more would really bring something.
|
I'd also really like to have this option: As I'm using prettier only in very few of my workspaces, some "opt-in behaviour" would be much smoother for my work. |
if you are only using it in very few projects/workspaces. Then you can disable it by default, and enable it where necessary. |
In my setup I can't enable for a given workspace. It is grayed out. But a similar behavior can be accomplished: workspace settings where needed: |
Well - I have like 20 plugins and many open source and internal projects I work on. Many awesome linting tools and similar plugins already do that and I guess the technical solution is quite easy to do. |
I'm confused now. You want an option to configure the extension so that it is enabled/disabled. But you don't want to configure the extension because you have too many projects? If you have an option that enables/disables it, you still have to configure it? |
Ah okay sorry for all the confusion :) My idea is as follows:
This would reduce the amount of project specific configuration for many plugin users. |
I would rather an option like this: |
I really want to avoid options. And even more when they seem to add something which is already possible. |
As soon as support for the prettier config files is in all the extensions most projects will use that to define project specific styling. Which means adhering to that is ideal. So detecting when a config for prettier exists already needs to be implemented, so why not add a case to not use prettier if the project doesn't have a config for prettier? I recognise it's another option, but surely this lends itself to being the most useful given users would never need to change the extension's settings again. If you only supported prettier's config files then you could potentially remove all other options from this extension, no? |
@jthegedus proposal makes more sens to me (it's something new). The problem with this is: |
For project I would say do what prettier does
And when there is no config do whatever prettier cli does when run without flags. Prettier has a |
You just described what's already happening.
This is not what was asked in this thread. It should be disabled. |
Of course! Sorry, I was distracted.
For simplicity in use and implementation, I would only support prettier config files. No default or global user setting. But that's me. Edit: the most popular opinion is surely a flag that does the default formatting or nothing. |
There has been some progress on this topic in the prettier-atom plugin repo. The conclusion they have come to (and appear to be implementing) is similar to what I was suggesting. My opinions on the implementation aside, it would be easier for users if the experience was the same across the prettier plugin ecosystem. Here's the particular discussion point prettier/prettier-atom#256 (comment) |
@jthegedus exactly that was what I had in mind when I opened the issue. Reduce the amount of configuration per project to zero and use the existing configuration from the prettier config. |
Sorry for creating so much noise @CiGit . It seems like prettier-atom is now going to leave most of their settings and add support for the config file. So no saved code there. Maybe a solution to reduce the codebase here is to support:
I'll mention it here since it's relevant, the question of managing |
@jthegedus Yeah, we had some back and forth on the prettier-atom implementation. I figured with the prettier config coming out, we could get rid of a huge amount of code (and I actually coded this up completely), but then there was some push back on that idea. As far as editorconfig, check out this PR: prettier/prettier#2760 |
I would still keep editor's settings. I see some use case where you don't want to setup a
|
FWIW we (prettier-atom) ended up keeping all the options and then merging them with the prettier options from the config file. Just a heads up, we are having a bunch of problems with backward-compatibility, so before merging, I would suggest making sure you can still use the new version of prettier-vscode with old versions of prettier (assuming you allow using local versions, not sure if you do that). |
I support the idea of only having this run on save if prettier is in the dependencies of the |
@timramsier I would suggest that it might be better to look for prettier configuration the way the atom plugin does it: by looking for a .prettierrc file or a "prettier" top-level property in package.json Searching specifically in dependencies (or devDependencies) would rule out those of us with prettier installed globally, or those of us who run it via |
ah, thanks, @robwise |
@jokeyrhyme |
I would also like a plugin that has the option to only enable when a project is using prettier. This would help a lot when using Prettier on only some projects. Not all projects have Prettier enabled by default. A lot of legacy open source projects use ESLint for their linting without disabling their formatting rules. To make matters worse, Prettier now conflicts with ESLint when ESLint is set up to work with the highly popular default AirBnB config. Using the advanced settings, and removing all of the javascript context items has multiple downsides:
Disabling this on a workspace context also has it's downsides:
[1]: We are free to choose our editor of choice. So I'm not going to add extra config files to our repos for VSCode and any other editor out there. Especially not for a setting that makes a lot of sense for a personal developer setup. Prettier should make things simpler, not harder. |
Really like the way how |
Took me a while to find the relevant conversations. I think it should work if the dependency is found in node_modules. This is the way it works the eslint plugin now. It looks for the dependency in node_modules. Otherwise, it says
This is the relevant conversation in the create-react-app repository. Before that, dependencies needed to be installed globally. Or needed to be listed locally in your dependencies. Now no, it is automatically picked up from your node_modules. |
Oh, the eslint plugin also requires to have a config file. Otherwise, you get
|
Are the maintainers open to a PR implementing something similar to the prettier-atom approach? I'm currently using the workaround to empty out the arrays globally and enabling on a per project basis but I'd rather have it happen more automatically based on my config. |
PR would be welcome. I really think searching for a config only would be enough. (package.json's "prettier" key included) ie |
@jcrben and @CiGit we need this now that VSCode support multi-root workspaces, and the existing workaround does not seem to be supported at the "Folder" config level. I have a multi-root workspace where one of the root projects uses prettier, and the other does not. And when I try the workaround in the folder specific vscode config I get the following warning: "This setting cannot be applied now. It will be applied when you open this folder directly." Seems we need this feature more than ever. |
I think I like the "only format if prettier is in |
@azz I see some troubles with that.
This approach is all or nothing. You can't open your project as a sub-project:
Advantage, we could remove it during extension initialization and don't implement it as a noop. (again multi-root ...) |
Good point, I retract mine. package.json search up the directory tree from the file being formatted up to the root directory? |
This could be a thing. But it limits to node projects. I still prefer relying on a prettier config which you can put in every projects. |
I like the idea of having a config file. I just don't like the idea of relying on a package.json. Because if we use something like create-react-app, prettier won't be listed in the dependencies but it will be available in node_modules. |
Works for me! |
Whether it's a setting |
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. |
Would it be possible to add an option which disables this extension if prettier is not installed in the root package json?
The text was updated successfully, but these errors were encountered: