question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule Proposal: no-array-destructured-return

See original GitHub issue

From 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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
ljharbcommented, Jan 11, 2017

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.

3reactions
nzakascommented, Jul 21, 2016

I’m not sure the name makes much sense. I’d see something like no-array-destructured-return as being easier to understand.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found