Skip to main content

One post tagged with "contributing"

View All Tags

Tips For Increasing Lint Rule Test Coverage

· 8 min read
Evyatar Daud
typescript-eslint Committer
Josh Goldberg
typescript-eslint Maintainer

In typescript-eslint, we aim for 100% code coverage when possible because lint rules can be extremely tricky, nuanced pieces of code. When a lint rule's source has an uncovered line, it's more than it "just" missing test coverage. It can also mean that rule logic written for an AST shape is not exercised, which means nothing has checked whether that branch does the right thing. Often it doesn't.

note

If someone linked you here from a pull request review that flagged uncovered lines in a lint rule: Hello! Thanks for contributing! This is one of the most common changes we request, and rather than retype the same explanation every time, we wrote it down.

Every coverage gap we've reviewed has come down to one of three answers: