revolution
revolution copied to clipboard
Enable autoformat code (before commit)
Feature request
Summary
The repository code should run through some code formatter like https://prettier.io/
Why is it needed?
- No need to discuss style in code review
Suggested solution(s)
Add prettier
at least to the template build process to make the files in that part formatted. The other part (format the php code) needs some integration in an IDE or in the commit process.
We should also provide the code styles in an Intellij IDEA code style XML scheme.
The code style of a PR should also be checked by Travis on GitHub and invalid styled code should be rejected.
Related issue(s)/PR(s)
Nothing special, but changing the default branch to 3.x would be a great time to introduce this change, since after reformatting our code we will have merge issues with code from other branches.
Should have been done a long time ago. The only problem is all the merge conflicts it is going to cause.
How can we move forward with this? I would really like to see a more standardised code base.
Use https://prettier.io/ for our IDE with a common config.
https://www.npmjs.com/package/grunt-prettier
There is a package milking Grunt. You can use it and write a config to format your code.
I studied the information on this topic. I have found:
- prettifer has Pre-commit Hook https://prettier.io/docs/en/precommit.html - this is exactly what we need
- the configuration file is extensive http://json.schemastore.org/prettierrc
We need to take the first step and begin to embody this innovation.
I suggest:
- discuss the set of rules for the .prettierrc configuration file.
- add the given file to the root directory
- and test
Colleagues, your move!
Does Prettier provide default rules? Maybe we can use that for a start.
There are libraries of this kind, for CSS, for example, https://github.com/csscomb
@Mark-H specified:
Perhaps we should discuss code styles on the forum. When there's consensus (maybe there already is), existing code should be converted and automatically enforced as part of the checks that run for each PR and commit.
That's not just about SCSS, but also JS and PHP should get that.
Does Prettier provide default rules? Maybe we can use that for a start.
https://prettier.io/docs/en/configuration.html