Lint only changed files in a git PR

Nice guide to lint only changed files (git)

Typically, code linters will lint the entire project and report back any violations across any file. This very safely accomplishes catching any error in a compliant project, but makes gradual adoption very hard. Itā€™s 100% buy-in and you canā€™t get the rewards until youā€™ve finished the process.

What if instead we state ā€œall new code should adopt these rulesā€. For each pull request, lint only the files that contain changes. Donā€™t bother linting files that this PR has left alone, because itā€™s not a regression and PRs need to have discipline in the tasks they complete. Over time, however, we might expect to see much of the codebase transformed, with maybe a little task at the end to clean up odds and ends. We can transform a big-upfront cost into a much more manageable process and de-risk the project significantly by gradually adopting a styleguide instead of Big Refactor Upfrontā„¢.