1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

build: lint cli/tests/unit using deno lint (#6327)

This commit is contained in:
Alan Gou 2020-06-19 02:05:37 -07:00 committed by GitHub
parent 36ad5e4402
commit ffedbd79ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 19 deletions

View file

@ -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()

View file

@ -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");

View file

@ -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"];

View file

@ -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"];

View file

@ -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
}
}
);

View file

@ -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);
});

View file

@ -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,

View file

@ -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;