diff --git a/.eslintrc.json b/.eslintrc.json index fe4830c..2e68576 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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" }], diff --git a/test/fixtures/typescript-no-errors-ignore-promise.ts b/test/fixtures/typescript-no-errors-ignore-promise.ts new file mode 100644 index 0000000..c364040 --- /dev/null +++ b/test/fixtures/typescript-no-errors-ignore-promise.ts @@ -0,0 +1,3 @@ +const returnsPromise = async (): Promise => {} + +void returnsPromise() diff --git a/test/validate-config.js b/test/validate-config.js index 35bf13d..1218126 100644 --- a/test/validate-config.js +++ b/test/validate-config.js @@ -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) +})