mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
build: lint cli/tests/unit using deno lint (#6327)
This commit is contained in:
parent
36ad5e4402
commit
ffedbd79ad
8 changed files with 42 additions and 19 deletions
|
@ -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()
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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"];
|
||||
|
|
|
@ -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"];
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue