You add linting to your project and suddenly you're faced with thousands of lint warnings and errors. What's the point? You're never going spend those hours upon hours fixing all of this. Or are you?
I use ESLint for linting on JavaScript projects.
If I start a project I add a set of linting rules (in the .eslintrc file) and an automated way of running them with tests or checkins and the project remains lint free. That's easy.
Adding lint rules to an established project is tough, especially if you have a set of predefined rules you want to use and they are generating more warnings and errors than you can address.
The best way, I've found, for adding a linter in this case is to:
- Add all your lint rules using the .eslintrc file.
- Run the linter and then disable each rule that is generating a warning or error until there are no more warnings or errors.
We all have times when things are not going well in the code base and we need to take a break to refresh, regroup and take another approach at what we're doing.
These breaks are perfect times to see if we can switch one of those disabled lint rules to a warning or error level and improve the quality of the code. It's also a great opportunity to scan over the entire code-base and re-familiarize yourself with parts that you'd forgotten about or parts that might be dead and can be removed.
No comments:
Post a Comment