False positive with `callback-return` rule
See original GitHub issueESLint 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:
- https://github.com/sindresorhus/gulp-size/blob/40c6c9af54046b7b45cf5b2e3df128da8236306c/test.js#L21
- https://github.com/sindresorhus/gulp-size/blob/40c6c9af54046b7b45cf5b2e3df128da8236306c/test.js#L82
- https://github.com/sindresorhus/gulp-size/blob/40c6c9af54046b7b45cf5b2e3df128da8236306c/test.js#L104
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:14 (13 by maintainers)
Top 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 >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’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.
This has been open for over a year and several team members have indicated that this is quite difficult, so closing.