From d4018e8933c228b014c50c313ce42f3cf94b739a Mon Sep 17 00:00:00 2001 From: Abraham Guo Date: Sun, 7 Jul 2024 19:06:40 -0500 Subject: [PATCH] add suggestions --- .../tests/rules/no-floating-promises.test.ts | 89 +++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) 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 67fc2265de86..8bfcd71c18ec 100644 --- a/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts +++ b/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts @@ -3760,7 +3760,21 @@ void myTag\`abc\`; declare const createPromise: () => PromiseLike; createPromise(); `, - errors: [{ line: 3, messageId: 'floatingVoid' }], + errors: [ + { + line: 3, + messageId: 'floatingVoid', + suggestions: [ + { + messageId: 'floatingFixVoid', + output: ` +declare const createPromise: () => PromiseLike; +void createPromise(); + `, + }, + ], + }, + ], options: [{ checkThenables: true }], }, { @@ -3773,7 +3787,26 @@ declare function createMyThenable(): MyThenable; createMyThenable(); `, - errors: [{ line: 8, messageId: 'floatingVoid' }], + errors: [ + { + line: 8, + messageId: 'floatingVoid', + suggestions: [ + { + messageId: 'floatingFixVoid', + output: ` +interface MyThenable { + then(onFulfilled: () => void, onRejected: () => void): MyThenable; +} + +declare function createMyThenable(): MyThenable; + +void createMyThenable(); + `, + }, + ], + }, + ], options: [{ checkThenables: true }], }, { @@ -3781,7 +3814,21 @@ createMyThenable(); declare const createPromise: () => Promise; createPromise(); `, - errors: [{ line: 3, messageId: 'floatingVoid' }], + errors: [ + { + line: 3, + messageId: 'floatingVoid', + suggestions: [ + { + messageId: 'floatingFixVoid', + output: ` +declare const createPromise: () => Promise; +void createPromise(); + `, + }, + ], + }, + ], options: [{ checkThenables: false }], }, { @@ -3790,7 +3837,22 @@ class MyPromise extends Promise {} declare const createMyPromise: () => MyPromise; createMyPromise(); `, - errors: [{ line: 4, messageId: 'floatingVoid' }], + errors: [ + { + line: 4, + messageId: 'floatingVoid', + suggestions: [ + { + messageId: 'floatingFixVoid', + output: ` +class MyPromise extends Promise {} +declare const createMyPromise: () => MyPromise; +void createMyPromise(); + `, + }, + ], + }, + ], options: [{ checkThenables: false }], }, { @@ -3801,7 +3863,24 @@ class MyPromise extends Promise { declare const createMyPromise: () => MyPromise; createMyPromise(); `, - errors: [{ line: 6, messageId: 'floatingVoid' }], + errors: [ + { + line: 6, + messageId: 'floatingVoid', + suggestions: [ + { + messageId: 'floatingFixVoid', + output: ` +class MyPromise extends Promise { + additional: string; +} +declare const createMyPromise: () => MyPromise; +void createMyPromise(); + `, + }, + ], + }, + ], options: [{ checkThenables: false }], }, ], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy