Closed
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
rules: {
// "spaced-comment": ["warn", "always"],
semi: ["error", "always"],
quotes: ["warn", "double"],
"prefer-const": "warn",
"no-underscore-dangle": "warn",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/type-annotation-spacing": "off",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/camelcase": "off",
**"@typescript-eslint/no-misused-promises": "error",**
"@typescript-eslint/no-floating-promises": "error"
}
async function reproduceIssue(parameterConditional: boolean) {
const myPromise = Promise.resolve(true);
const localTrue = true;
const localFalse = false;
// This correctly shows a bad usage
if (myPromise) {
console.log("Bad usage");
}
// This correctly shows a bad usage
if (localTrue && myPromise) {
console.log("Bad usage");
}
// This correctly not marks a bad usage
if (localFalse && myPromise) {
console.log("Bad usage");
}
// This should show a bad usage
if (parameterConditional && myPromise) {
console.log("Bad usage");
}
// This should show a bad usage
if (returnTrue() && myPromise) {
console.log("Bad usage");
}
}
function returnTrue(): boolean {
return true;
}
Expected Result
These lines should mark the promise as misused, but as they are applied an AND with an unknown boolean parameter or function result, they don't:if (parameterConditional && myPromise) {
if (this.returnTrue() && myPromise) {
Actual Result
Those lines are not marked as misuses of the promise but they are.
Additional Info
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.1.0 |
@typescript-eslint/parser |
4.1.0 |
TypeScript |
3.9.7 |
ESLint |
7.8.1 |
node |
12.8.3 |