-
Notifications
You must be signed in to change notification settings - Fork 281
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
Migrate to ESLint #1944
Merged
Merged
Migrate to ESLint #1944
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit e5381b4.
joeloff
reviewed
Sep 10, 2024
joeloff
approved these changes
Sep 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
TSLint was deprecated when this project had no maintainer.
We waited a while to migrate because there was no real reason to.
I followed https://code.visualstudio.com/api/advanced-topics/tslint-eslint-migration to help migrate.
Nowadays TSLint is failing a lot in our pipeline and having sporadic behavior. This might be due to upgrading to node 20. Or maybe due to the .editorconfig. I figured now was the time to migrate.
This introduced about 900 new linting errors. I fixed some of them. For files with no code churn, I disabled the linter for those files. If/when we touch those files again, we can fix those issues then. Some of them are very time consuming and don't make sense to test unless we are editing the pre-existing behavior because it's already a 'known-good.'
Linting Issues
One of the errors I did add a disable on a per line basis was unsafe member access. Unfortunately this only checks against calling
.
on theany
type, not whether accessing.foo
is safe to call (e.g.x?.bar
is OK, but notx.bar
whenx
isany
and could this beundefined
ornull
.)But I didnt want to disable it project wide because without the ? it is actually a serious problem. But in JS anything can be thrown (not just exception) so we want to catch it all. But that makes eslint very mad.
So I resorted to commenting on it everywhere in the code which is ugly, but there doesn't seem to be a better option for now, unless we want to only catch errors, but some libraries will throw stuff up that's not an error because yay javascript
https://stackoverflow.com/questions/66462386/how-to-handle-the-typescript-eslint-no-unsafe-member-access-rule-on-catcherr
Why ES Lint 8
There is a thing called ES Lint 9. That seems to not really support migrating from an eslintrc.js file. And that is the file type that's created when you want to convert from a tslint project to lint typescript. Even their tooling says dont do this yet.