core icon indicating copy to clipboard operation
core copied to clipboard

Clean build artifacts locally before linting

Open mcmire opened this issue 1 year ago • 2 comments

Explanation

If you run yarn build and then run ESLint (either in your editor or the eslint CLI), you may see false positives — i.e., you may see lint errors show up on CI, but when you try to reproduce them locally, they mysteriously disappear. I am not 100% sure why this happens, but I believe it's because when the TypeScript-backed ESLint rules run, TypeScript will parse the type declaration files that were generated via yarn build and use them as a reference instead of using the live version of the TypeScript files, so if the type declaration files are out of date, then the results of ESLint will also be out of date. Ensuring that all build artifacts are removed before linting makes these false positives go away.

This commit adds the lint:clean-only package script and then adds it as a prerequisite for lint, lint:fix, and build.

References

Changelog

(There are no functional changes in this PR)

Checklist

  • [x] I've updated the test suite for new or updated code as appropriate
  • [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate

mcmire avatar Jun 10 '24 17:06 mcmire

I tried reproducing an example lint failure that you shared with me on Zoom, and was unable to. I am not totally sure about the premise here, that the linter uses build files. It should be operating just on the source files as far as I know.

Gudahtt avatar Jun 24 '24 14:06 Gudahtt

Interesting, alright. I too was a bit skeptical of my theory. I'll keep this open in case it comes up again.

mcmire avatar Jun 24 '24 22:06 mcmire