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.

Returning undefined triggers no-return-assign

See original GitHub issue
  • ESLint Version: 5.5.0
  • Node Version: 10.6.0
  • npm Version: 6.4.1

Default configuration; () => void (a = 1) triggers the no-return-assign rule even though it’s returning undefined.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Sep 2, 2018

(to clarify, i don’t think this is a bug - the rules docs have the title of “Disallow Assignment in return Statement” - it’s in no way about the return value or the result of the assignment, and the description points out that the motivation is to catch the bug of doing = when you meant to do == or ===.

Because of this ambiguity, it’s considered a best practice to not use assignment in return statements.

There should be no exception here for void (imo there shouldn’t be one for parens either). At the worst, void could be under another option (like except-parens) but I don’t think there’s value in that versus the added rule complexity.

1reaction
ljharbcommented, Sep 2, 2018

The rule isn’t warning about returning the result of an assignment - it’s warning about having an assignment expression inside a return statement. Adding void doesn’t change that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MongoDB Atlas scheduled trigger service returning undefined
get('mongodb-atlas'); is returning undefined when I log it to console, and when I try and using it, it just says Cannot access member...
Read more >
Scheduled trigger service returning undefined - MongoDB Atlas
I'm trying to create a scheduled trigger to clear a collection weekly, but I am unable to get the service… const collection ...
Read more >
Low level issues - Embold Help Center
A confusing aspect of JavaScript is that a function returns undefined if any of the following are true: 1. it does not execute...
Read more >
AdditionalScope passed to Query Trigger in Javascript Query ...
I am a passing the additionalScope function to the query.trigger method ... passed to Query Trigger in Javascript Query returning Undefined.
Read more >
backend/static/build/static/js/18.2480c5a6.chunk.js.map
openClassName;\n\n if (openClassName !== undefined) {\n return ... className,\n overlay = props.overlay,\n trigger = props.trigger,\n align ...
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