Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/eslint-plugin/docs/rules/no-floating-promises.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ await createMyThenable();
</TabItem>
</Tabs>

:::info
This option is enabled by default in v7 but will be turned off by default in v8.
:::

### `ignoreVoid`

This option, which is `true` by default, allows you to stop the rule reporting promises consumed with void operator.
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-floating-promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default createRule<Options, MessageId>({
{
allowForKnownSafeCalls: readonlynessOptionsDefaults.allow,
allowForKnownSafePromises: readonlynessOptionsDefaults.allow,
checkThenables: true,
checkThenables: false,
ignoreIIFE: false,
ignoreVoid: true,
},
Expand Down
24 changes: 9 additions & 15 deletions packages/eslint-plugin/tests/rules/no-floating-promises.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,25 +770,19 @@ createSafePromise();
},
],
},
{
code: `
declare const createPromise: () => PromiseLike<number>;
createPromise();
`,
options: [{ checkThenables: false }],
},
{
code: `
`
declare const createPromiseLike: () => PromiseLike<number>;
createPromiseLike();
`,
`
interface MyThenable {
then(onFulfilled: () => void, onRejected: () => void): MyThenable;
}

declare function createMyThenable(): MyThenable;

createMyThenable();
`,
options: [{ checkThenables: false }],
},
`,
],

invalid: [
Expand Down Expand Up @@ -2104,6 +2098,7 @@ async function test() {
],
},
],
options: [{ checkThenables: true }],
},
{
code: `
Expand Down Expand Up @@ -3586,6 +3581,7 @@ promise;
options: [
{
allowForKnownSafePromises: [{ from: 'file', name: 'SafeThenable' }],
checkThenables: true,
},
],
errors: [
Expand Down Expand Up @@ -3962,7 +3958,6 @@ void createPromise();
],
},
],
options: [{ checkThenables: false }],
},
{
code: `
Expand All @@ -3986,7 +3981,6 @@ void createMyPromise();
],
},
],
options: [{ checkThenables: false }],
},
{
code: `
Expand Down Expand Up @@ -4014,7 +4008,7 @@ void createMyPromise();
],
},
],
options: [{ checkThenables: false }],
options: [{ checkThenables: true }],
},
],
});