-
-
Notifications
You must be signed in to change notification settings - Fork 456
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
Custom Prettier Resolution #232
Comments
Seems totally reasonable to me. I think typescript has a similar setting. |
If I understood correctly your file system looks like
I think we can update our local resolution algorithm to resolve this case. Resolve from package.json's folder. ➕ No new settings (and we wouldn't have to do that for other modules we have) ➖ Still won't resolve a randomly installed prettier (global install, ...) |
I'd be just as happy with either solution. |
+1 |
Same issue here, with mono repo
yarn workspace is hoisting |
another use case that needs that - prettier is hoisted as part of lerna configuration, what left for lerna sub-package is only symlink to hoisted npm module |
Any update on this? I think the original proposal seems ideal whereas it provides max flexibility. As I understand it I don't think the proposal of updating the local resolution algorithm would work on my project. We have a cli tool (that can live anywhere) that handles running various things across projects for us including formatting code. It would be very helpful to be able to specify the path of the prettier executable similar to what the SublimeText plugin does. |
The resolution algorithm has just been updated but not yet released. #342 I'd like to avoid adding options. If your project depends on prettier, why not having it inside it's dependencies? In the future with more language support (Java / python / ...), It may make sens. |
I think creating an algorithm to try and intelligently determine which prettier module to use is reasonable. That being said if you don't have a way of overriding the prettier resolution you are restricting this tool projects that happen to follow the organization patterns your algorithm is expecting. In my case the opinionated nature of this tool make it unfeasible to use at work and on various side projects I have. A few examples include:
These are just meant as two illustrates but I feel confident additional use cases could be found. Regardless IMO it seems less ideal that the official prettier extension would also appear to be indirectly opinionated about file organizational structure, a topic which has nothing to do with prettier in my mind. Bottom line is I like the tool and would like to use it but in its current form I can't. Hope a solution can be found. |
That's fair.
This would also be an option we would have to add. Prettier cli allows it. Side effect: It would be faster to format as we now where to search ;-) |
What about a 3-state option ?
Option name up for bikeshedding ! We also would have to think about future plugins. How would it work with them? |
It'd be great if the package fell back to a globally installed Prettier before using a built-in one, because global Prettier can also go with some plugins installed. Global Prettier plugins will be discoverable soon in 1.13, because prettier/prettier#4000 has been fixed. I implemented falling back to a global Prettier in Atom, see prettier/prettier-atom#397. Would something similar be acceptable for VSCode too? |
How are you searching for that global prettier? Asking users to input theirs installation would cover more use case I presume. And speed up the thing. |
In Ptrettier for Atom (prettier/prettier-atom#397), I proposed to search for Prettier installed globably via npm and yarn — both of these locations can be easily derived on any os. I don't know of any other method to install Prettier globally as of now. Perhaps, letting users to specify a custom copy of prettier could be useful to someone too, but I'm not sure it would be needed by many (perhaps, mainly for developers) |
To install global package, you have to be root on most systems. Other package manager may work differently tho. (You may even have your distribution packaging it for you) You could even set your config to point to something which isn't prettier but a fork or an other tool with the same API. (I'm not sure if I should put that in pros or cons ...). We could imagine prettier-**lint wrapper 😄 |
This is only the case for Linux, because homebrewed npm on macOS or a bundled Node+npm for Windows don't require admin permissions. Even if admin rights are needed, it's still easier to globally install, say, Prettier and Indeed, people can install Prettier globally anyhow they want. If the VSCode plugin uses Prettier via CLI, it will always able to find it (regardless of if it's local or global). Scanning global IMO it makes sense to search for Prettier in this order:
It should work well for all people and I can't imagine a situation when it surprises someone. If a person wants to use a custom copy of Prettier for a particular project or workspace, they simply change a corresponding |
Another use-case to consider is support for forks like prettier-miscellaneous. I have prettier-miscellaneous installed locally, but the plugin does not seem to detect it and instead uses its bundled prettier install. |
Is there any workaround at the moment? |
Another use case is formatting TOML files via |
Another resolution scenario to consider is with Yarn PnP/v2. When using Yarn PnP the package is installed in the project but not extracted to node_modules. |
The setting has been added in version 3.0 |
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. |
Instead of needing to have prettier installed in your current folder's
node_modules
directory it'd be nice to have the option to specify where you'd like the extension to look for your prettier installation. Resolution strategy would be as follows:The issue I ran into: I'm using yarn workspaces and it hoists dependencies if they're shared between different workspaces. Because of this my prettier installation isn't in the individual workspace's node_modules folder. It'd be nice to have the ability to set the following in my
.vscode/settings.json
file:Thoughts?
The text was updated successfully, but these errors were encountered: