Luke Lee

Luke Lee

Senior Backend Engineer

Octopus Energy

Lint All the Things!

Many teams document the conventions for their projects. However, documentation gets out of date, forgotten, or sometimes ignored. Simple documentation requires team members to constantly remember all the ‘rules’ for your project. You can better enforce those rules and free up your team members to think about harder problems using linting tools like flake8, import linter, and pre-commit.

These tools provide tons of useful stuff out of the box, but you can push them so much further with customization. This allows your project to formally document conventions, but also enforce them automatically on every commit, merge, and build. This can make code reviews faster and more focused on the problems your code is meant to solve.

This talk will introduce tools like flake8, import linter, and pre-commit along with some of their built-in functionality. Then, we’ll briefly explore some ways to customize them to fit your projects’ specific needs. Some examples of custom linter rules we’ll tour are:

  • Code formatted automatically and uniformly
  • Code doesn’t import across architecture layers violating separation of concerns
  • Common conventions are used
  • Common anti-patterns are avoided
  • Specific layers are fully tested
  • Proper git commit message formatting
  • Merge commits don’t exist in topic/feature branches

Finally, we’ll discuss ways to use those custom linter rules on every commit, merge, and build with continuous integration or git hooks.