callback-return not working for calls immediately preceding returns
See original GitHub issueTell 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:
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:
- Created 4 years ago
- Comments:12 (11 by maintainers)
Top 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 >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
@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).
Making a new issue would be great. We’ve seen that discussions on closed/stale issues tend to not get much discussion.