-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 def0e8a
☁️ Nx Cloud last updated this comment at |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11720 +/- ##
========================================
Coverage 90.66% 90.67%
========================================
Files 518 519 +1
Lines 52435 52621 +186
Branches 8686 8721 +35
========================================
+ Hits 47541 47714 +173
- Misses 4880 4893 +13
Partials 14 14
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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
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.
[Testing] Some more "fun" cases to check:
- Function overloads (including function overloads that report)
- Destructured tuples
- Usage of the built-in
Partialtype
Some of those already work, it'd just be good to have more unit tests for them to be safe.
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 ✨ <git@joshuakgoldberg.com>
…t.mdx Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
…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 🚀 |

PR Checklist
Overview
Reports useless default values.