Use Static Testing Tools

Linters, type checkers, and even formatters are incredibly powerful tools that can help guide our codebases and avoid runtime errors. They replace fine grained low level tests that nobody will write anyway. It can be easy to offload thinking to overly ambitious linting tools. These can cause you to write verbose code or do weird things just to satisfy them. A linting rule must justify its existence. Formatters save enormous amounts of time and arguments about silly things that don't matter. Use one and move on.

Examples

  • Instead of writing a test to see what happens when you pass a string to a function that expects a number, simply add type definitions for that function and any callers (if you avoid `any` then you're even safer than the test can make you).
  • You have strict PPI compliance regulations you must follow, so you write some custom linting rules to help avoid logging of user sensitive information.