-
Notifications
You must be signed in to change notification settings - Fork 512
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
Improve formatting configuration #2183
Improve formatting configuration #2183
Conversation
Hey @ahobsonsayers, I think this is a great addition. Sometimes I have problems because I use a different IDE (WebStorm), and always forget to check the formatting with vscode. Can you add an EditorConfig file? Prettier enforces formatting after saving, while EditorConfig enforces formatting during editing. (https://stackoverflow.com/questions/48363647/editorconfig-vs-eslint-vs-prettier-is-it-worthwhile-to-use-them-all#comment110968436_48471763) I started to use this on the project:
|
Great idea @mfcar! I have now added an I have also added equivalent settings to the vscode json for those that use vscode but dont have the editorconfig extension (although i have added the editor config extension as a workspace recommendation!) One caveat is that prettier does not allow cofiguring whether a final new line is inserted or not. It is very opinionated on this and there is no way to change its behaviour on this References about this: Out of interest, what is the reason for no trailing newline? Im not bothered by it either way, but im interested in the choice 🙂 |
I've noticed that many files don't have an empty line at the end, but as a personal preference, I prefer having an empty new line. In my opinion, it helps me better distinguish the end of the file 😁 |
I also prefer a new line at the end of the file, and there are a lot of good reasons why it is good practice too. Maybe it is ok then that prettier enforces the new line at the end, better than having a mixture of some files with it and some files without right? Consistency is king! Is this something that this project is going to be ok with? |
I'm good with enforcing a newline at the end of the file. I've been testing the [warn] Ignored unknown option { editorconfig: true }. There are a few changes prettier is making that I'll have to get used to but I think this is great. |
Thanks for the reply @advplyr
Wonderful, i have updated the config in the latest commit to reflect this.
Thanks for spotting this. Fixed it in the latest commit by removing it. Related to this issue: prettier/prettier#6176 |
I ended up putting this in cb1ebd4 excluding the prettier formatter for now since that was updating every file that I couldn't review in one sitting. Mentioned here #2853 (comment) |
When developing my first contrbution to this repo in #2182 , I noticed that the configuration of the formatting could be improved slightly to help people developing in VSCode and other IDEs, as well as aid with keeping consistent formatting across the codebase - assuming this is what you want. This was particularly relevant to me as I noticed when editing some existing files in my other PR, that my IDE was trying to format it differently to how it currently was, which i had to be careful to avoid.
I have moved your prettier config from the vscode settings to a
.prettierrc
file so that it is IDE agnostic - vetur will still use this config. Additionally i have added prettier to the dev dependancies and added a task to run prettier across all files should you wish to do this at some point (I did not run this for this PR).I hope these improvements simply help contributers know the formatting this project would like, allows them to easily ensure they are meeting the style and helps avoid changing the formatting of existing files.
If this is not what is wanted, please let me know, it just seemed like an easy win that I think is helpful (well for me at least)