Open phillip-le opened 2 months ago
Why is linting important? We shouldn't be focussing on things that can be lintable in pull
reviewsrequests. Investing in automation has massive ROIs. From a developer perspective, it is a lot easier to digest a machine telling you what you're doing wrong than receiving a dozen comments on a PR.
Also shortens the feedback cycles as you're writing code, and reduces the time for PR reviews as reading the code is much easier and adheres to the team's coding patterns.
Suppose there are three broad categories for code quality:
eslint
best practices, no unused variablesWhat I want to talk about is how we can slowly raise the bar for the lowest level. In other words, how to introduce new linting rules.
First, pick a linting rule that you want to adopt.
Add it to your
eslint
config and set it aterror
. It is important to NOT set it aswarn
because it is very commonly ignored and very hard to prevent new linting violations from being introduced. What we want to see is that the number of violations decreases over time.Use
eslint --fix
to take care of the easiest cases.Then, use https://github.com/mizdra/eslint-interactive to add individual
disable-eslint
lines with aTODO
comment on every instance of the rule violation. Usually, for large codebases, the effort to retroactively make a codebase compliant is huge and not worth it but the benefits of preventing future instances can be huge for quality.Optionally, create a codemod that will attempt to autofix the problem like https://docs.grit.io/patterns
https://eslint.org/docs/latest/use/command-line-interface#--report-unused-disable-directives Ensures that every disable eslint comment is having an affect. Helps with simplicity over time.
Why is linting important? We shouldn't be focussing on things that can be lintable in pull reviews. Investing in automation has massive ROIs. From a developer perspective, it is a lot easier to digest a machine telling you what you're doing wrong than receiving a dozen comments on a PR.
Also, shill for
ls-lint
andknip