You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!
I think it would be valuable to support for some type of file that contains prettier's config so that projects can check it in source control.
I can see 2 cases where this would be useful.
Allow tools to know that the project is using prettier. I'd like to enable thing like format on save but I don't want to reformat everyfile I touch on a project that doesn't use prettier.
Allow per project config to avoid the need to change options when changing projects or to have to create custom formating scripts.
Could be it's own file (something like .editorconfig) or maybe part of package.json.
Reacted by Matt, Filipe Fortes, Robert J Samson, dive2Pro, Meriadec Pillet, Forbes Lindesay, Oktavianus Ludiro, Jonathan Petitcolas, Caige Nichols, Manuel Bieh and 57 more
We aim to be zero-config. For now at least, I am against this. The few existing config options only exist to help applying to existing projects, and should only be used if you really need to. We will see what happens over time, but for now I'll point you to #40
Reacted by Graham McGregor, Justin Ross and Thomas Hibbard
Reacted by Peter Petrov, Alyx, Prateek Jain, Gregory, Mathieu Schroeter, Iddan Aaronsohn, 无止休, Einar Löve, Erik Cupal, Richard Oliver Bray and 19 more
I like the idea of having no or very few config, but would also like a way to tell tools that a project uses prettier (see my first point). I feel like this is needed if we want to adopt auto formatting progressively for JS. We cannot do like Reason or Go did because these languages had something like this from the start so every project uses them and there is no need to tell tools if auto formatting should be used.
I would very much like this tool to be configureable. In particular, I use trailing commas in files that are compiled via babel, but it's not an option (in function calls) for files that are not compiled.
I do think it should work, and do something people are mostly happy with, without a config. It seems to mostly do that, which is great.
I also think we need to make sure that if you're using something like create-react-app, it just works out of the box.
Would you consider a pull request that added support for a .prettier config file, defaulting to the current behaviour in it's absence?
Reacted by Josh Burgess, Peter Petrov, Alex Hayes, ManAnRuck and Jule Breckel
@vramana I'm not asking for more configuration options. I'm happy to just enable/disable trailing commas across the board.
What I want is a file to store settings in so I can use the atom plugin/cli without issues even on projects that do not use the defaults for every config option.
Reacted by Josh Burgess, Pedro A. Melendez, Peter Petrov, Dan Homola, Alex Hayes and Casey
Would you consider a pull request that added support for a .prettier config file, defaulting to the current behaviour in it's absence?
Not at this point in the project. I'd really like to avoid it, as explained below. Never say never, but this project is only a few days old, and my preference is to evolve slowly. If we can solve problems a different way that don't require an additional piece of infrastructure, everybody wins.
There are already so many project-level configs. While we are sorting things out, an atom plugin itself could read from a .prettier file and the community can try it out without us supporting it natively yet.
What I want is a file to store settings in so I can use the atom plugin/cli without issues even on projects that do not use the defaults for every config option.
Here's the real reason I don't think we need it: you shouldn't have to worry about what settings the project has. One of the hidden benefits with this kind of printer is that we're closer to the ideal where text is stored in a generic format and you can view it however you like. Another project has different settings than you? Who cares! Just open a file and format it according to your preferred settings. When you go to make a commit, the project should have a way to auto-format the changes files back to its own preferred settings (we'll work on this toolchain soon).
I think the JS ecosystem could hugely benefit from this given that it's probably the most diverse group of opinions because it's so large. It's a chance to end the endless debates because it doesn't matter what's committed anymore: you can reformat and read code in your preferred settings, and reformat it back before committing. Worst case if some unformatted code gets through, the CLI will fail when it checks to make sure everything is formatted in the "formal" way.
Reacted by Antoine Lehurt, Conor Hastings, Danny Martini, Eric Ferraiuolo, Paulo Ragonha and Michael Rybka
I like the idea of having no or very few config, but would also like a way to tell tools that a project uses prettier (see my first point).
@vjeux has some ideas about this. I think a simple solution could be for an editor plugin to search for node_modules and check it prettier exists within it. We don't need a config file just to see if a project uses it.
The problem is that not everyone will adopt a tool like this all at once, thus the "generic format" for text needs to match the project's existing conventions. Disallowing config will mean that adopting prettier is an all-or-nothing approach, unless the project just happens to already comply with the convention prettier chooses, which - for the exact reasons you mention that the ecosystem could benefit from this tool - will prevent adoption of it, on any larger scale.
Reacted by Chris Dhanaraj, Forbes Lindesay, Oktavianus Ludiro, Samuel Martineau, Yo Wakita, Matthew Kimball-Cobbs, Christian Naths, Jon Crenshaw, Søren Louv-Jansen, Mike Kusold and 9 more
My use case is that at work the coding convention is different then the coding convention I prefer for personal projects, and I need prettier to integrate with my IDE.
Here is my hack for adding a configuration file for prettier:
And here is my IntelliJ External Tool configuration:
Reacted by kitze 🚀, Chris Pearce, Stanislav Ivanov, Rhys Lloyd, Peter Petrov, abdullah-kasim, Alexey Taktarov, Jule Breckel, Florian Mettetal, Dmytro Teslitsky and 4 more
Here's the real reason I don't think we need it: you shouldn't have to worry about what settings the project has. One of the hidden benefits with this kind of printer is that we're closer to the ideal where text is stored in a generic format and you can view it however you like.
@jlongster I understand why you're trying to avoid project config options. I love the idea that each developer can view the code-base of a project with any formatting rules they prefer, but the repo keeps all the code formatted the way the project prefers.
But... we have a different use-case that may require them. We have multiple separate projects, each in its own repo, and we want all the projects in our organization to share the same prettier rules (which are different than the default). Is there a way to share them that's DRY and doesn't require copy-pasting them across repos?
@oztune Probably the best option for you is to fork prettier-standard-formatter and set your own config options here. Publish to npm when done for easy sharing.
Alternatively, using my comment above, you can create config files, then use npm scripts to run prettier.
@kusold Thanks for that link! Both of those are very practical solutions, but I'm also interested to hear from the authors if they intend to address this need formally.
I have to say it doesn't make much sense to require each and every editor to setup a prettier config individually. It really should be editor independent. Some people want trailing commas, no semis, single quotes, etc... If a project sets a list of these rules, contributors have to manually setup the proper rules to match the project according to the maintainers' preferences, which doesn't make sense. These rules should already be set for them by a configuration file in the project so that anyone using any editor doesn't have to do any extra setup to adhere to the project's style...
Reacted by Rhys Lloyd, Peter Petrov, Dan Homola, Sander Vispoel, Konstantin Mikhailov, Chris Krycho, Michael Rybka, Sylvain Dumont, Benjamin Schwarze, Daniel Reszka and 2 more
@joshburgess Very good points. Maybe the editor integrations should have an option to format with the project specific preferences or format in your own style.
I think that people should stop using ESLint for styling related issues because prettier handles them better. In the other hand ESLint is pretty good at catching common errors like no default case in switch or unused variable.
Is this still something that's ever gonna happen. I would be all for one way to write JS, but that's just not how the world works these days. Prettier has boiled it down to very few options though which is great. My problem is that I am working for different people and in one project they insist on semicolons and in the other they insist on no semicolons. It's not up to me to decide, so the only way around not having to go to the prettier atom settings every time I work on a different project would be having settings. Maybe they could be just inside the package.json, I don't care, but this is really cumbersome if you don't just work in one environment.
@vjeux If this is going to be .prettier or similar, please consider searching in the .config directory in the project root, (a place for large projects with many config files to store config files to tidy up the root directory).
It's not a well adopted standard yet, but the more projects that do this, the more widespread it will become.
Reacted by Tobias Lohse, Tyler Kelley and Jason Kuhrt
Reacted by Jordan Harband, Vitor Balocco and Steve Purcell
I'd prefer, like all projects everywhere else, for my config dotfiles to remain at the root of the repo. ls hides dotfiles by default, so there's no need to "tidy up" anything.
I think that's a misunderstanding @ljharb the suggestion is not to only look in a .config dir for a config file, but to look in this dir additionally to of course looking in the root dir.
Thanks for clarifying, as long as it prioritizes "root" over "root/.config", I'd have no objection to it looking in ".config" for those who prefer that style.
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!
Activity
jlongster commentedon Jan 11, 2017
We aim to be zero-config. For now at least, I am against this. The few existing config options only exist to help applying to existing projects, and should only be used if you really need to. We will see what happens over time, but for now I'll point you to #40
janicduplessis commentedon Jan 11, 2017
I like the idea of having no or very few config, but would also like a way to tell tools that a project uses prettier (see my first point). I feel like this is needed if we want to adopt auto formatting progressively for JS. We cannot do like Reason or Go did because these languages had something like this from the start so every project uses them and there is no need to tell tools if auto formatting should be used.
ForbesLindesay commentedon Jan 13, 2017
I would very much like this tool to be configureable. In particular, I use trailing commas in files that are compiled via babel, but it's not an option (in function calls) for files that are not compiled.
I do think it should work, and do something people are mostly happy with, without a config. It seems to mostly do that, which is great.
I also think we need to make sure that if you're using something like create-react-app, it just works out of the box.
Would you consider a pull request that added support for a
.prettierconfig file, defaulting to the current behaviour in it's absence?vramana commentedon Jan 13, 2017
@ForbesLindesay @jlongster has said in another thread the he may consider allowing an option to configure function trailing commas.
Have you seen this https://github.com/kentcdodds/prettier-eslint?
ForbesLindesay commentedon Jan 13, 2017
@vramana I'm not asking for more configuration options. I'm happy to just enable/disable trailing commas across the board.
What I want is a file to store settings in so I can use the atom plugin/cli without issues even on projects that do not use the defaults for every config option.
jlongster commentedon Jan 13, 2017
Not at this point in the project. I'd really like to avoid it, as explained below. Never say never, but this project is only a few days old, and my preference is to evolve slowly. If we can solve problems a different way that don't require an additional piece of infrastructure, everybody wins.
There are already so many project-level configs. While we are sorting things out, an atom plugin itself could read from a
.prettierfile and the community can try it out without us supporting it natively yet.Here's the real reason I don't think we need it: you shouldn't have to worry about what settings the project has. One of the hidden benefits with this kind of printer is that we're closer to the ideal where text is stored in a generic format and you can view it however you like. Another project has different settings than you? Who cares! Just open a file and format it according to your preferred settings. When you go to make a commit, the project should have a way to auto-format the changes files back to its own preferred settings (we'll work on this toolchain soon).
I think the JS ecosystem could hugely benefit from this given that it's probably the most diverse group of opinions because it's so large. It's a chance to end the endless debates because it doesn't matter what's committed anymore: you can reformat and read code in your preferred settings, and reformat it back before committing. Worst case if some unformatted code gets through, the CLI will fail when it checks to make sure everything is formatted in the "formal" way.
jlongster commentedon Jan 13, 2017
@vjeux has some ideas about this. I think a simple solution could be for an editor plugin to search for
node_modulesand check itprettierexists within it. We don't need a config file just to see if a project uses it.ljharb commentedon Jan 13, 2017
The problem is that not everyone will adopt a tool like this all at once, thus the "generic format" for text needs to match the project's existing conventions. Disallowing config will mean that adopting prettier is an all-or-nothing approach, unless the project just happens to already comply with the convention prettier chooses, which - for the exact reasons you mention that the ecosystem could benefit from this tool - will prevent adoption of it, on any larger scale.
kusold commentedon Apr 18, 2017
My use case is that at work the coding convention is different then the coding convention I prefer for personal projects, and I need prettier to integrate with my IDE.
Here is my hack for adding a configuration file for prettier:
You can then do:
And here is my IntelliJ External Tool configuration:

kitze commentedon Apr 25, 2017
@kusold you're a lifesaver 🖐
oztune commentedon Apr 28, 2017
@jlongster I understand why you're trying to avoid project config options. I love the idea that each developer can view the code-base of a project with any formatting rules they prefer, but the repo keeps all the code formatted the way the project prefers.
But... we have a different use-case that may require them. We have multiple separate projects, each in its own repo, and we want all the projects in our organization to share the same prettier rules (which are different than the default). Is there a way to share them that's DRY and doesn't require copy-pasting them across repos?
kusold commentedon Apr 28, 2017
@oztune Probably the best option for you is to fork prettier-standard-formatter and set your own config options here. Publish to npm when done for easy sharing.
Alternatively, using my comment above, you can create config files, then use npm scripts to run prettier.
oztune commentedon Apr 28, 2017
@kusold Thanks for that link! Both of those are very practical solutions, but I'm also interested to hear from the authors if they intend to address this need formally.
joshburgess commentedon May 14, 2017
I have to say it doesn't make much sense to require each and every editor to setup a prettier config individually. It really should be editor independent. Some people want trailing commas, no semis, single quotes, etc... If a project sets a list of these rules, contributors have to manually setup the proper rules to match the project according to the maintainers' preferences, which doesn't make sense. These rules should already be set for them by a configuration file in the project so that anyone using any editor doesn't have to do any extra setup to adhere to the project's style...
2 remaining items
k15a commentedon May 14, 2017
@joshburgess Very good points. Maybe the editor integrations should have an option to format with the project specific preferences or format in your own style.
I think that people should stop using ESLint for styling related issues because prettier handles them better. In the other hand ESLint is pretty good at catching common errors like no default case in switch or unused variable.
joshburgess commentedon May 14, 2017
@k15a For whatever it's worth, I'm reading this thread #1086 right now, and it seems to offer a promising solution.
That sounds good to me. I don't really care if it's a standalone config file or a few lines in the package.json, as long as it solves the problem.
MrLoh commentedon Jul 7, 2017
Is this still something that's ever gonna happen. I would be all for one way to write JS, but that's just not how the world works these days. Prettier has boiled it down to very few options though which is great. My problem is that I am working for different people and in one project they insist on semicolons and in the other they insist on no semicolons. It's not up to me to decide, so the only way around not having to go to the prettier atom settings every time I work on a different project would be having settings. Maybe they could be just inside the package.json, I don't care, but this is really cumbersome if you don't just work in one environment.
vjeux commentedon Jul 7, 2017
This is going to happen. We're working out the details right now
mbrookes commentedon Jul 8, 2017
@vjeux If this is going to be
.prettieror similar, please consider searching in the.configdirectory in the project root, (a place for large projects with many config files to store config files to tidy up the root directory).It's not a well adopted standard yet, but the more projects that do this, the more widespread it will become.
ljharb commentedon Jul 9, 2017
I'd prefer, like all projects everywhere else, for my config dotfiles to remain at the root of the repo.
lshides dotfiles by default, so there's no need to "tidy up" anything.MrLoh commentedon Jul 9, 2017
I think that's a misunderstanding @ljharb the suggestion is not to only look in a
.configdir for a config file, but to look in this dir additionally to of course looking in the root dir.ljharb commentedon Jul 9, 2017
Thanks for clarifying, as long as it prioritizes "root" over "root/.config", I'd have no objection to it looking in ".config" for those who prefer that style.
mbrookes commentedon Jul 9, 2017
@ljharb ls does, but github doesn't, and yes, that's the way it would work.
azz commentedon Jul 10, 2017
As of #2434, the current default won't search
.configdirectories, but you can passprettier --config .config/.prettierrcto the CLI.