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.

False positive with `callback-return` rule

See original GitHub issue

ESLint 1.1.0. Concerning the callback-return rule.

Config

'callback-return': [2, ['cb', 'callback']]

Problem

function foo(bool, bool2, cb) {
    function bar() {
        if (bool2) {
            console.log('foo');
            cb();
        }
    }

    if (bool) {
        bar();
    } else {
        cb();
    }
}

I have many instances of this and similar code where I have a conditional whether to do something more or callback right away.

In the above example, both of the cb calls violates the callback-return rule. It should not however, as there is no code running after the cb() calls. So it’s totally safe.

Some real examples:

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
xjamundxcommented, Oct 18, 2016

I’d really love to figure this one out as I think it can add a ton of value. Just leave it closed and if I can figure out how to do it with the code path stuff I’ll shout.

0reactions
nzakascommented, Sep 1, 2016

This has been open for over a year and several team members have indicated that this is quite difficult, so closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[array-callback-return] False positive when in a map that uses ...
I have read the FAQ and my problem is not listed. Repro. The rule array-callback-return is enabled with default settings. There are no...
Read more >
How to satisfy the lint rules 'array-callback-return'?
This issue is caused by not returning a value when using map() , see how the results are expected according to the docs......
Read more >
False Positive Tests in Jest with Promises! | by td - Medium
1. The test should return the Promise who's resolution behaviour is under test. Assume `getData()`when resolved will return 'Hi' · 2. The test ......
Read more >
Axe API Documentation - Deque Systems
Provides list of rules and elements that passed accessibility checking, ensuring rules have been run against entire document; Only checks rendered content to ......
Read more >
6480 Validation: Typescript Code Smell - Sonar Community
We have the Typescript rule 6480 enabled, that states: The problem is, that I … ... Clean Code Report False-positive / False-negative.
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