eslint-plugin-promise
eslint-plugin-promise copied to clipboard
False positive of `isInsideCallback` for functions with first arg named `err`/`error`
Description
I'm using no-promise-in-callback rule and defining top-level function with err (or error) parameter.
Once I use Promise.resolve outside of return context, it reports an error.
Steps to Reproduce
Enable no-promise-in-callback and check this code:
function fn(err) {
return { promise: Promise.resolve(err) };
}
Expected behavior: no warning inside functions top-level functions, methods or static methods.
Actual behavior: warnings that are confusing at first. Check out my actual code example:
static err<E>(err: NonNullable<E>): AsyncResult<never, E> {
return new AsyncResult(Promise.resolve(Result.err(err)));
}
Versions
[Please fill this in if you are submitting a bug report]
- Node version:
18 - ESLint version:
8.45.0 - eslint-plugin-promise version:
6.1.1
Additional Information
Probably, this line is the root cause.