Rule Proposal: no-array-destructured-return
See original GitHub issueFrom disallowArrayDestructuringReturn.
This rule will prevent to receive returned values with array destructuring as the favor of named returned values.
I think this rule should allow array destructuring with rest elements: let [head, ...rest] = foo();
{
"no-nameless-multiple-return": "error"
}
Valid:
let {left, right} = foo();
let [head, ...rest] = foo();
Invalid:
let [a, b] = foo();
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:10 (10 by maintainers)
Top Results From Across the Web
ESLint: prefer-destructuring - Styleguide JavaScript
Use object destructuring for multiple return values instead of array destructuring. New properties can not be added over time or the order of...
Read more >New Rule: `prefer-destructuring` · Issue #1931 - GitHub
i.e. the rule causes a type error due to attempting to convert a non-iterable to an array destructure. #723 is about const x:...
Read more >Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >Destructuring in combination with array functions [duplicate]
Just wondering if it's possible to use an array function (like filter) to return both the negative and the positive outcomes of the...
Read more >Destructuring Arrays & Objects: JavaScript ES6 Feature Series ...
Simply by adding an empty space in the destructured array, you can choose not to return the value 'orange' from the function ignoreColor()...
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 agree on changing the name. JS does not have multiple return - it only ever has single return. Destructuring is a caller-side shortcut that unpacks a single array or object.
I’m not sure the name makes much sense. I’d see something like
no-array-destructured-return
as being easier to understand.