DEV Community

Discussion on: How to painlessly turn on ESLint rules

Collapse
 
kayone profile image
theOnlyKay

As an alternative, consider using husky with lint-staged. This workflow allows you to keep updating your lint rules, but will only enforce them in a pre-commit hook for staged files. This means that untouched files won't be linted though, so may not be ideal for every scenario (I use this on a solo project, and I don't have a CI pipeline yet)

See here: medium.com/gits-apps-insight/utili...

Collapse
 
hjylewis profile image
Henry Lewis

Yeah, I've actually done something similar in the past. It really depends on the developers and the code base. That approach proves difficult when you have CI running a validation check on your entire code base.

Another disadvantage I found with that approach was that often PRs became filled with unrelated changes which made them hard to review. The pre-commit hook forces you to make changes to a file that you are just trying to make a small change to and might not know super well.

What's nice about esplint is that it alerts you to the violations and prevents new ones but also lets you fix the old violations at your own pace. Again, it really depends on the developers and the code base in question.