-
Notifications
You must be signed in to change notification settings - Fork 312
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
Soften wording for rule to avoid using default in switch statements #245
Conversation
0c9b5c3
to
6a49a47
Compare
Worked with @bachand to workshop and simplify the changes |
Thanks for taking the time to work through this one together @calda . The large number of places in our codebase that are in conflict with this rule as well as the reasonable exceptions that we discussed (partially documented in the new examples) convinced that we should in fact soften the wording. |
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.
🎉
Co-authored-by: Michael Bachand <michael.bachand@airbnb.com>
Summary
We have a rule that suggests to avoid using the
default
case when switching over an enum.This rule is worded pretty strongly ("never use the
default
case"), but lacks autocorrect or linting, so has no enforcement. I also think there are valid reasons to use the default case.I think we should just soften the wording of this rule (not use strict wording like "never"), since it is still good advice overall.
Some alternatives we could consider:
default
. The prose rule includes a set of exceptions where it can make sense to usedefault
.default
case. (edit: Michael has suggested some heuristics we could use to reduce the number of false positives here without needing full type information).Reasoning
Please react with 👍/👎 if you agree or disagree with this proposal.