no-nil doesn't seem to understand default switch case
See original GitHub issueconst reducer = (state = {}, action) => {
switch (action.type) {
case 'CHANGE_TEXT':
return { text: action.payload };
default:
return state;
}
};
This function will always return something, but sadly I get the error Function must end with a return statement, so that it doesn't return undefined fp/no-nil
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:10 (3 by maintainers)
Top Results From Across the Web
What if I don't write default in switch case? - Stack Overflow
The code is valid. If there is no default: label and none of the case labels match the "switched" value, then none of...
Read more >Don't Understand Default Case in Switch Statement - Activities
I don't understand how the default activity is supposed to work in Switch. My statement returns a string. I made sure that the...
Read more >switch Statement (C) - Microsoft Learn
The default statement is executed if no case constant-expression value is equal to the value of expression . If there's no default statement, ......
Read more >Switch statements: `default` doesn't have to be the last case
This idea is from an SO answer by JaredPar. He continues to clarify: "This means default will run if, and only if, the...
Read more >Is it necessary to add the default case while using switch cases?
It seems there are three cases when a default statement is not necessary: no other cases are left, because there is a limited...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found another construct to support: try/catch.
I get this error (and
fp/no-nil
too) for class constructors also, .e.g: