Skip to content

Commit

Permalink
fix: allow to ignore floating promise with void operator: `@typescrip…
Browse files Browse the repository at this point in the history
…t-eslint/no-floating-promises`
  • Loading branch information
theoludwig committed May 21, 2024
1 parent 815518c commit 10b5a0d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"no-useless-return": "error",
"no-else-return": ["error", { "allowElseIf": false }],
"no-var": "error",
"no-void": "error",
"no-void": ["error", { "allowAsStatement": true }],
"no-with": "error",
"object-shorthand": ["error", "properties"],
"one-var": ["error", { "initialized": "never" }],
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/typescript-no-errors-ignore-promise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const returnsPromise = async (): Promise<void> => {}

void returnsPromise()
7 changes: 7 additions & 0 deletions test/validate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ test("ensure we allow top-level await", async () => {
)
assert.strictEqual(lintResult?.errorCount, 0)
})

test("ensure we allow to ignore floating promise with void operator (@typescript-eslint/no-floating-promises)", async () => {
const [lintResult] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors-ignore-promise.ts",
)
assert.strictEqual(lintResult?.errorCount, 0)
})

0 comments on commit 10b5a0d

Please sign in to comment.