diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index b3ac65296992..b9fb9b1cc4dd 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -290,6 +290,8 @@ export default createRule({ // All other cases are unhandled. return { isUnhandled: true }; + } else if (node.type === AST_NODE_TYPES.TaggedTemplateExpression) { + return { isUnhandled: true }; } else if (node.type === AST_NODE_TYPES.ConditionalExpression) { // We must be getting the promise-like value from one of the branches of the // ternary. Check them directly. diff --git a/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts b/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts index 434c9735a46d..bd02ed6d5a87 100644 --- a/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts +++ b/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts @@ -504,6 +504,18 @@ void promiseArray; ['I', 'am', 'just', 'an', 'array']; `, }, + { + code: ` +declare const myTag: (strings: TemplateStringsArray) => Promise; +myTag\`abc\`.catch(() => {}); + `, + }, + { + code: ` +declare const myTag: (strings: TemplateStringsArray) => string; +myTag\`abc\`; + `, + }, ], invalid: [ @@ -593,6 +605,43 @@ doSomething(); }, ], }, + { + code: ` +declare const myTag: (strings: TemplateStringsArray) => Promise; +myTag\`abc\`; + `, + errors: [ + { + line: 3, + messageId: 'floatingVoid', + }, + ], + }, + { + code: ` +declare const myTag: (strings: TemplateStringsArray) => Promise; +myTag\`abc\`.then(() => {}); + `, + errors: [ + { + line: 3, + messageId: 'floatingVoid', + }, + ], + }, + { + code: ` +declare const myTag: (strings: TemplateStringsArray) => Promise; +myTag\`abc\`.finally(() => {}); + `, + errors: [ + { + line: 3, + messageId: 'floatingVoid', + }, + ], + }, + { options: [{ ignoreVoid: true }], code: `