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.

callback-return not working for calls immediately preceding returns

See original GitHub issue

Tell us about your environment

Node version: v10.16.0 npm version: v6.13.7 Local ESLint version: v6.8.0 (Currently used) Global ESLint version: Not found

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

1581359005.zip

Configuration
module.exports = {
    "extends": "eslint:all",
    "env": {
        "es6": true
    }
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

index_1.js:

(() => {
    "use strict";

    const object = {
        "test": (callback) => {
            if (callback) {
                callback();
            }
        }
    };

    object.test2 = 42;
})();

index_2.js:

(() => {
    "use strict";

    const object = {
        "test": (callback) => {
            if (callback) {
                callback();

                return;
            }
        }
    };

    object.test2 = 42;
})();
./node_modules/.bin/eslint index_1.js index_2.js

What did you expect to happen?

Only report error for index_1.js file.

What actually happened? Please include the actual, raw output from ESLint.

/Users/revolt/1581359005/index_1.js
  11:17  error  Expected return with your callback function  callback-return

/Users/revolt/1581359005/index_2.js
  13:17  error  Unnecessary return statement  no-useless-return

✖ 2 problems (2 errors, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

Are you willing to submit a pull request to fix this bug?

Maybe.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
G-Rathcommented, Mar 20, 2020

@kaicataldo I’ve created #13064 - apologises for the title; it’s been a long day and couldn’t find of a more concise way to expression the problem (since its not actually only assignments).

1reaction
kaicataldocommented, Mar 20, 2020

Making a new issue would be great. We’ve seen that discussions on closed/stale issues tend to not get much discussion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When does the useEffect's callback's return statement execute?
Surely the problem with that idea is, useEffect 's return would immediately cancel the timer before the timer's callback had a chance to...
Read more >
callback-return - ESLint - Pluggable JavaScript Linter
This rule is aimed at ensuring that callbacks used outside of the main function block are always part-of or immediately preceding a return...
Read more >
React callback ref cleanup function · Issue #15176 - GitHub
The only case where it isn't backward compatible is if currently someone is returning a function and doesn't expect the function to be...
Read more >
Paho Python MQTT Client - Understanding Callbacks
I have a problem understanding callbacks and loops. I just want to create a function, that returns the last sent message on a...
Read more >
Twilio Function Execution
Please note that all samples demonstrate using the return keyword before calling callback . This is to prevent subsequent code from unintentionally running ......
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