Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean build artifacts locally before linting #4396

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Jun 10, 2024

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

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

@mcmire mcmire requested a review from a team as a code owner June 10, 2024 17:38
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 ESLint rules that make use of TypeScript
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 a clean step to both `yarn lint` and `yarn lint:fix`,
and it also ensures that the clean step precedes the build step for
consistency.
@mcmire mcmire requested a review from a team June 21, 2024 19:46
@Gudahtt
Copy link
Member

Gudahtt commented Jun 24, 2024

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.

@mcmire
Copy link
Contributor Author

mcmire commented Jun 24, 2024

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

@mcmire mcmire marked this pull request as draft June 25, 2024 23:34
package.json Outdated Show resolved Hide resolved
Co-authored-by: Jongsun Suh <jongsun.suh@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants