diff options
author | Alan Gou <alan@frontapp.com> | 2020-06-19 02:05:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-19 11:05:37 +0200 |
commit | ffedbd79ad90bc88ef8c51d145536f68f50d4fea (patch) | |
tree | c774772d18867fe08a87429446c473be2fc856c5 | |
parent | 36ad5e44020a8bd48546e5a8bdb7db9c2f40dc52 (diff) |
build: lint cli/tests/unit using deno lint (#6327)
-rw-r--r-- | cli/tests/integration_tests.rs | 1 | ||||
-rw-r--r-- | cli/tests/unit/console_test.ts | 4 | ||||
-rw-r--r-- | cli/tests/unit/dispatch_json_test.ts | 6 | ||||
-rw-r--r-- | cli/tests/unit/dispatch_minimal_test.ts | 6 | ||||
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 8 | ||||
-rw-r--r-- | cli/tests/unit/globals_test.ts | 30 | ||||
-rw-r--r-- | cli/tests/unit/streams_transform_test.ts | 4 | ||||
-rwxr-xr-x | cli/tests/unit/unit_test_runner.ts | 2 |
8 files changed, 42 insertions, 19 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 235d6ce11..cbd0dbc26 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -37,6 +37,7 @@ fn std_lint() { .arg("lint") .arg("--unstable") .arg(util::root_path().join("std")) + .arg(util::root_path().join("cli/tests/unit")) .spawn() .unwrap() .wait() diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 98e43c739..7634ff0e1 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -608,7 +608,9 @@ unitTest(async function consoleTestStringifyPromises(): Promise<void> { rej(Error("Whoops")); }); await rejectedPromise; - } catch (err) {} + } catch (err) { + // pass + } const strLines = stringify(rejectedPromise).split("\n"); assertEquals(strLines[0], "Promise {"); assertEquals(strLines[1], " <rejected> Error: Whoops"); diff --git a/cli/tests/unit/dispatch_json_test.ts b/cli/tests/unit/dispatch_json_test.ts index ebb8217e3..938f4f6e3 100644 --- a/cli/tests/unit/dispatch_json_test.ts +++ b/cli/tests/unit/dispatch_json_test.ts @@ -19,13 +19,13 @@ unitTest( } ); -/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-explicit-any,no-var */ declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace namespace Deno { - var core: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var core: any; // eslint-disable-line no-var } } -/* eslint-enable */ unitTest(function malformedJsonControlBuffer(): void { const opId = Deno.core.ops()["op_open"]; diff --git a/cli/tests/unit/dispatch_minimal_test.ts b/cli/tests/unit/dispatch_minimal_test.ts index 12cf4595c..f46c0e575 100644 --- a/cli/tests/unit/dispatch_minimal_test.ts +++ b/cli/tests/unit/dispatch_minimal_test.ts @@ -25,13 +25,13 @@ unitTest(async function sendAsyncStackTrace(): Promise<void> { } }); -/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-explicit-any,no-var */ declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace namespace Deno { - var core: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var core: any; // eslint-disable-line no-var } } -/* eslint-enable */ unitTest(function malformedMinimalControlBuffer(): void { const readOpId = Deno.core.ops()["op_read"]; diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index 98ff42737..b3de5ac4d 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -747,7 +747,9 @@ unitTest({ perms: { net: true } }, async function fetchBodyReadTwice(): Promise< fail( "Reading body multiple times should failed, the stream should've been locked." ); - } catch {} + } catch { + // pass + } } }); @@ -768,7 +770,9 @@ unitTest( try { response.body.getReader(); fail("The stream should've been locked."); - } catch {} + } catch { + // pass + } } ); diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts index ccea6e74c..116df1698 100644 --- a/cli/tests/unit/globals_test.ts +++ b/cli/tests/unit/globals_test.ts @@ -47,7 +47,9 @@ unitTest(function webAssemblyExists(): void { /* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-explicit-any,no-var */ declare global { + // deno-lint-ignore no-namespace namespace Deno { + // deno-lint-ignore no-explicit-any var core: any; } } @@ -58,37 +60,51 @@ unitTest(function DenoNamespaceImmutable(): void { try { // eslint-disable-next-line @typescript-eslint/no-explicit-any (Deno as any) = 1; - } catch {} + } catch { + // pass + } assert(denoCopy === Deno); try { // eslint-disable-next-line @typescript-eslint/no-explicit-any (window as any).Deno = 1; - } catch {} + } catch { + // pass + } assert(denoCopy === Deno); try { delete window.Deno; - } catch {} + } catch { + // pass + } assert(denoCopy === Deno); const { readFile } = Deno; try { // eslint-disable-next-line @typescript-eslint/no-explicit-any (Deno as any).readFile = 1; - } catch {} + } catch { + // pass + } assert(readFile === Deno.readFile); try { delete window.Deno.readFile; - } catch {} + } catch { + // pass + } assert(readFile === Deno.readFile); const { print } = Deno.core; try { Deno.core.print = 1; - } catch {} + } catch { + // pass + } assert(print === Deno.core.print); try { delete Deno.core.print; - } catch {} + } catch { + // pass + } assert(print === Deno.core.print); }); diff --git a/cli/tests/unit/streams_transform_test.ts b/cli/tests/unit/streams_transform_test.ts index f3ec148ae..c8b4528e8 100644 --- a/cli/tests/unit/streams_transform_test.ts +++ b/cli/tests/unit/streams_transform_test.ts @@ -506,7 +506,7 @@ unitTest(async function transformStreamStartCalledOnce() { unitTest(function transformStreamReadableTypeThrows() { assertThrows( - // eslint-disable-next-line + // eslint-disable-next-line @typescript-eslint/no-explicit-any () => new TransformStream({ readableType: "bytes" as any }), RangeError, undefined, @@ -516,7 +516,7 @@ unitTest(function transformStreamReadableTypeThrows() { unitTest(function transformStreamWirtableTypeThrows() { assertThrows( - // eslint-disable-next-line + // eslint-disable-next-line @typescript-eslint/no-explicit-any () => new TransformStream({ writableType: "bytes" as any }), RangeError, undefined, diff --git a/cli/tests/unit/unit_test_runner.ts b/cli/tests/unit/unit_test_runner.ts index 38db545c7..b2e872200 100755 --- a/cli/tests/unit/unit_test_runner.ts +++ b/cli/tests/unit/unit_test_runner.ts @@ -13,7 +13,7 @@ import { reportToConn, } from "./test_util.ts"; -// @ts-expect-error +// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol const internalObj = Deno[Deno.internal]; // eslint-disable-next-line @typescript-eslint/no-explicit-any const reportToConsole = internalObj.reportToConsole as (message: any) => void; |