How to create Style Guide for your team that will suit everyone
OurCodeStyle - create style guide that will best suit your team, or just have fun voting for code style options, find people who have same preferences.
Ruby and JavaScript both have static code analyzers and formatters, like
RuboCop, and ESLint, among most used.
This tools come with a set of rules, and rule options which can be configured based on your preferences, the problem is that people in the team might have different preferences.
Me and my team have been using this tools for a while, and we find some rules useful, some are of ambiguous benefit. For such cases we used Slack bot to vote if we want some rule to be ON or on particular configs of the rule.
But Slack is not very convenient for this, so in my free time I have made a site which contains all the rules from RuboCop and ESLint with their options and params, which can then generate proper .rubocop.yml file based on voting.
But why limit to only own team, I have made it accessible for everyone.
Voting
At above example there is 2 options for a Cop Style/LambdaCall: call, braces.
You can see examples of each option, and vote for your option.
See in action: Style/LambdaCall
Consensus
By default an option wins when it has at least 2 votes more than other options, and at least 3 votes in total (it can be configured for each team separately).
I found it that 50%+1 vote is usually not a good idea, you should configure this for your team needs.
Config Generation
After you have some consensus on options you can generate configuration for linter.
You receive a static link to your generated config, you can either download it and put into project, or add it to your current config as external inheritance source.
Code Style Mates
As you start to vote on options more and more, you can notice that your votes are matching with some other people on your team. To track this better there is a widget in your profile showing people you have most matches, it means your taste on code style is very similar.
Master Style Guide & Your Own
You can use site in 2 ways:
- You can create your organization, create style guides in it and vote with your team
- Or there is one public organization, called Master, where everyone can vote, this way we can build a collective mind style guide.
Free Form Guide
In addition to RuboCop and ESLint, you can create a free form guide, which you can populate with your own pools, for example if you can solve one problem in several ways and don't know which to choose, just crate an Enum type pool, paste your code blocks and ask your teammates to vote. Syntax highlighting for free form is:
- ruby
- javascript
- python
- java
- php
- go
- kotlin
- perl
- rust
- elixir
Please comment if you find it useful or have any issues or proposals
Top comments (8)
This looks awesome! I'm definitely gonna take a test drive with this! I have a Github repo where I store my 'personal' Rubocop config, but this is a really cool way to source opinions on all the different rules!
One thing I noticed while browsing around, that it would be really cool to have some kind of mode where it shows me different rules and gives me the option to vote on them, or skip if I don't have a strong opinion! That way I can just keep being prompted with new rules, instead of manually finding ones I care about!
Do you mean something like tinder, so system has a list of featured (interesting) rules you might want to look onto?
Ya that's exactly what I was thinking lol great example I hadn't thought of that
One more thing! I'm also getting an unauthorized error when I try to edit the consensus rules for an organization I just made. Just wanted to let you know!
Thank you for reply, will check this and fix, its just first day of going live, I tested most of it but very helpful when some one makes report, thanks
Please try now to update consensus config
This is so awesome!! Are you keeping this maintained?