Skip to content

Commit 10b5a0d

Browse files
committed
fix: allow to ignore floating promise with void operator: @typescript-eslint/no-floating-promises
1 parent 815518c commit 10b5a0d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"no-useless-return": "error",
141141
"no-else-return": ["error", { "allowElseIf": false }],
142142
"no-var": "error",
143-
"no-void": "error",
143+
"no-void": ["error", { "allowAsStatement": true }],
144144
"no-with": "error",
145145
"object-shorthand": ["error", "properties"],
146146
"one-var": ["error", { "initialized": "never" }],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const returnsPromise = async (): Promise<void> => {}
2+
3+
void returnsPromise()

test/validate-config.js

+7
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ test("ensure we allow top-level await", async () => {
3737
)
3838
assert.strictEqual(lintResult?.errorCount, 0)
3939
})
40+
41+
test("ensure we allow to ignore floating promise with void operator (@typescript-eslint/no-floating-promises)", async () => {
42+
const [lintResult] = await eslint.lintFiles(
43+
"test/fixtures/typescript-no-errors-ignore-promise.ts",
44+
)
45+
assert.strictEqual(lintResult?.errorCount, 0)
46+
})

0 commit comments

Comments
 (0)