-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(eslint-plugin): [no-useless-default-assignment] add rule #11720
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
base: main
Are you sure you want to change the base?
feat(eslint-plugin): [no-useless-default-assignment] add rule #11720
Conversation
|
Thanks for the PR, @ulrichstark! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 026fd7f
☁️ Nx Cloud last updated this comment at |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11720 +/- ##
==========================================
+ Coverage 90.53% 90.58% +0.04%
==========================================
Files 523 524 +1
Lines 53097 53325 +228
Branches 8838 8892 +54
==========================================
+ Hits 48074 48302 +228
Misses 5010 5010
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great start, I love how readable this implementation is! 👏 nicely done.
Requesting changes mostly on getting test coverage up and covering edge cases. I suspect you'll have to tweak the implementation a little to deal with tuples. Cheers!
packages/eslint-plugin/docs/rules/no-useless-default-assignment.mdx
Outdated
Show resolved
Hide resolved
| default: | ||
| return null; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Non-Actionable] I'm surprised a utility doesn't already exist for this - but I couldn't find one.
getStaticValue: doesn't handle identifiersgetStringIfConstant: doesn't handle identifiers (it's a small wrapper aroundgetStaticStringValue)getStaticStringValue: didn't handle identifiers properly
Not requesting changes, just noting - maybe I missed one?
packages/eslint-plugin/tests/rules/no-useless-default-assignment.test.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/tests/rules/no-useless-default-assignment.test.ts
Show resolved
Hide resolved
packages/eslint-plugin/docs/rules/no-useless-default-assignment.mdx
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/docs/rules/no-useless-default-assignment.mdx
Outdated
Show resolved
Hide resolved
…t.mdx Co-authored-by: Josh Goldberg ✨ <[email protected]>
…t.mdx Co-authored-by: Josh Goldberg ✨ <[email protected]>
…ignment]-add-rule
|
Thanks Josh for your review! I already made all low effort changes. Do you also want me to turn the suggestion into a fix? I think it's safe in every case the project is properly typed. |
|
Yes let's do that 🚀 |
|
100% test coverage 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great, thanks for the coverage improvements! Just a couple points from me.
packages/eslint-plugin/docs/rules/no-useless-default-assignment.mdx
Outdated
Show resolved
Hide resolved
…ignment]-add-rule
…ignment]-add-rule
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely work, thanks! 🙌
@ronami had a bunch of good points I'd missed last review cycle, so if they have time it'd be good to hear from them too.
ronami
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀🚀 Looks amazing!
I've added two comments for bugs around destructuring records/mapped-types.
ed0011c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely work! 🏆
Requesting one final adjustment for records/mapped-types around the noUncheckedIndexedAccess compiler option.
ronami
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀🚀

PR Checklist
Overview
Reports useless default values.