re: How do you ensure your Team's code is consistent? VIEW POST


A basic way to ensure code style consistency is to pick a specific coding style and use a code style tool like eslint to make sure all the code in the project is consistent. If you aren't particularly opinionated and just want a basic ruleset to follow, there are specific configurations you can find. Assuming you're doing JavaScript development, there are packages like Standard JS and xo which basically simplify linting even further by having their own style rulesets you can plop into a project with basically no configuration. Other languages have various code style checkers as well.

Even if you don't use one of these automated tools, you should also specifically document your coding standards somewhere. If you look at any sizable open source project you'll typically find it has some kind of "Coding Standards Guide" somewhere that lists out the various standards they use for the code in the project. They probably use automated tools to check coding standards as well, but reading through a written document is much easier than parsing through JSON configuration for one of those linter tools.

Of course, having a linter tell you when your code doesn't match the basic coding style guidelines doesn't mean anything if you don't actively pursue coding consistency. If you want to make sure your team's code is consistent, you need to ensure that consistency when reviewing each other's code. If someone wants to merge a branch that doesn't match coding standards, it shouldn't be merged in until it does match those standards.


Thanks for commenting ;)

Checking an open source project sounds like a great idea! also about persuing consistent code, is there something that can be used to review code before it's being merged?


I'm not an expert in that specific area of tools, but I do believe there are tools to review code and automatically report that on pull requests or otherwise show the build as failing (as if you checked in code with failing unit tests) if code styles don't pass.

Code of Conduct Report abuse