phillip-le / phillip-le.github.io

https://phillip-le.github.io/
1 stars 0 forks source link

Raising the bar for code quality at scale #73

Open phillip-le opened 2 months ago

phillip-le commented 2 months ago

Suppose there are three broad categories for code quality:

What 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 at error. It is important to NOT set it as warn 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 a TODO 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 and knip

193F17A8-4931-4E83-A080-27CEB4E68808

udaniesalgado commented 2 days ago

Why is linting important? We shouldn't be focussing on things that can be lintable in pull reviews requests. 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.