From 798904b0f2ed0c7284b67bba2f125f406b5850de Mon Sep 17 00:00:00 2001 From: Samrith Shankar Date: Fri, 20 Mar 2020 14:38:34 +0100 Subject: Add require-await lint rule (#4401) --- cli/tests/018_async_catch.ts | 2 +- cli/tests/async_error.ts | 1 + cli/tests/async_error.ts.out | 8 ++++---- cli/tests/permission_test.ts | 3 ++- cli/tests/top_level_for_await.js | 2 +- cli/tests/top_level_for_await.ts | 1 + 6 files changed, 10 insertions(+), 7 deletions(-) (limited to 'cli/tests') diff --git a/cli/tests/018_async_catch.ts b/cli/tests/018_async_catch.ts index 0d034d798..a16f11696 100644 --- a/cli/tests/018_async_catch.ts +++ b/cli/tests/018_async_catch.ts @@ -1,4 +1,4 @@ -async function fn(): Promise { +function fn(): Promise { throw new Error("message"); } async function call(): Promise { diff --git a/cli/tests/async_error.ts b/cli/tests/async_error.ts index 81c983a50..b37369bac 100644 --- a/cli/tests/async_error.ts +++ b/cli/tests/async_error.ts @@ -1,4 +1,5 @@ console.log("hello"); +// eslint-disable-next-line require-await const foo = async (): Promise => { console.log("before error"); throw Error("error"); diff --git a/cli/tests/async_error.ts.out b/cli/tests/async_error.ts.out index d07ba8cfe..6e22799c2 100644 --- a/cli/tests/async_error.ts.out +++ b/cli/tests/async_error.ts.out @@ -2,10 +2,10 @@ before error world error: Uncaught Error: error -[WILDCARD]tests/async_error.ts:4:9 +[WILDCARD]tests/async_error.ts:5:9 -4 throw Error("error"); +5 throw Error("error"); ^ - at foo ([WILDCARD]tests/async_error.ts:4:9) - at [WILDCARD]tests/async_error.ts:7:1 + at foo ([WILDCARD]tests/async_error.ts:5:9) + at [WILDCARD]tests/async_error.ts:8:1 diff --git a/cli/tests/permission_test.ts b/cli/tests/permission_test.ts index 763e429b6..11b95cf3a 100644 --- a/cli/tests/permission_test.ts +++ b/cli/tests/permission_test.ts @@ -3,8 +3,9 @@ const { args, listen, env, exit, makeTempDirSync, readFileSync, run } = Deno; const name = args[0]; const test: { [key: string]: Function } = { - async readRequired(): Promise { + readRequired(): Promise { readFileSync("README.md"); + return Promise.resolve(); }, writeRequired(): void { makeTempDirSync(); diff --git a/cli/tests/top_level_for_await.js b/cli/tests/top_level_for_await.js index fa3b496a8..54742ce52 100644 --- a/cli/tests/top_level_for_await.js +++ b/cli/tests/top_level_for_await.js @@ -1,4 +1,4 @@ -async function* asyncGenerator() { +function* asyncGenerator() { let i = 0; while (i < 3) { yield i++; diff --git a/cli/tests/top_level_for_await.ts b/cli/tests/top_level_for_await.ts index 9179322d7..92d8af30a 100644 --- a/cli/tests/top_level_for_await.ts +++ b/cli/tests/top_level_for_await.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line require-await async function* asyncGenerator(): AsyncIterableIterator { let i = 0; while (i < 3) { -- cgit v1.2.3