New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
callback-return not working for calls immediately preceding returns #12899
Comments
Can you confirm that the error you are reporting as incorrect is actually coming from the If so, I actually think we should see if |
How can I confirm that? If it helps, I already have attached the entire project in the original issue. It looks to me like those 2 rules are contradicting each other, and I expected for this case to be detected and correctly handled. The documentation for
Hence why I expected for |
I just wanted to clarify, since the issue title is reporting I think |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
@kaicataldo, is it complicated to implement? |
@revolter I'm still not clear on what the issue is. Do you mind clarifying what you're asking about? |
@kaicataldo this might belong in another issue, but I'm going to put this here for now as it seems similar enough. Overall I think For example: const mutate = <TObject extends object, TKey extends keyof TObject>(
obj: TObject,
key: TKey,
callback: (value: TObject[TKey]) => TObject[TKey]
): void => {
obj[key] = callback(obj[key]);
}; This should not be flagged by Additionally, putting a const mutate = <TObject extends object, TKey extends keyof TObject>(
obj: TObject,
key: TKey,
callback: (value: TObject[TKey]) => TObject[TKey]
): void => {
if(process.env.ENABLE_CALLBACKS) {
obj[key] = callback(obj[key]);
return;
}
doSomething();
}; I don't think the rules interaction with Let me know if you'd like me to make a fresh issue to track this :) |
Making a new issue would be great. We've seen that discussions on closed/stale issues tend to not get much discussion. |
@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). |
Much appreciated! |
Why do you think this? If I have a function that returns void, and a callback that returns something else, I don't want to return it, but only to exit after the callback is called, and in this case,
But it wouldn't work for: (() => {
"use strict";
const object = {
"test": (callback) => {
if (callback) {
callback();
}
alert("something else");
}
};
object.test2 = 42;
})(); in which case, I would like to be able to have: (() => {
"use strict";
const object = {
"test": (callback) => {
if (callback) {
callback();
return;
}
alert("something else");
}
};
object.test2 = 42;
})(); and |
Actually, yes. I tested it again, and adding some code after that return makes it work correctly. |
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
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
: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.
Are you willing to submit a pull request to fix this bug?
Maybe.
The text was updated successfully, but these errors were encountered: