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("lint")
|
||||||
.arg("--unstable")
|
.arg("--unstable")
|
||||||
.arg(util::root_path().join("std"))
|
.arg(util::root_path().join("std"))
|
||||||
|
.arg(util::root_path().join("cli/tests/unit"))
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.wait()
|
.wait()
|
||||||
|
|
|
@ -608,7 +608,9 @@ unitTest(async function consoleTestStringifyPromises(): Promise<void> {
|
||||||
rej(Error("Whoops"));
|
rej(Error("Whoops"));
|
||||||
});
|
});
|
||||||
await rejectedPromise;
|
await rejectedPromise;
|
||||||
} catch (err) {}
|
} catch (err) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
const strLines = stringify(rejectedPromise).split("\n");
|
const strLines = stringify(rejectedPromise).split("\n");
|
||||||
assertEquals(strLines[0], "Promise {");
|
assertEquals(strLines[0], "Promise {");
|
||||||
assertEquals(strLines[1], " <rejected> Error: Whoops");
|
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 {
|
declare global {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
namespace Deno {
|
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 {
|
unitTest(function malformedJsonControlBuffer(): void {
|
||||||
const opId = Deno.core.ops()["op_open"];
|
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 {
|
declare global {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
namespace Deno {
|
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 {
|
unitTest(function malformedMinimalControlBuffer(): void {
|
||||||
const readOpId = Deno.core.ops()["op_read"];
|
const readOpId = Deno.core.ops()["op_read"];
|
||||||
|
|
|
@ -747,7 +747,9 @@ unitTest({ perms: { net: true } }, async function fetchBodyReadTwice(): Promise<
|
||||||
fail(
|
fail(
|
||||||
"Reading body multiple times should failed, the stream should've been locked."
|
"Reading body multiple times should failed, the stream should've been locked."
|
||||||
);
|
);
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -768,7 +770,9 @@ unitTest(
|
||||||
try {
|
try {
|
||||||
response.body.getReader();
|
response.body.getReader();
|
||||||
fail("The stream should've been locked.");
|
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 */
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-explicit-any,no-var */
|
||||||
declare global {
|
declare global {
|
||||||
|
// deno-lint-ignore no-namespace
|
||||||
namespace Deno {
|
namespace Deno {
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
var core: any;
|
var core: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,37 +60,51 @@ unitTest(function DenoNamespaceImmutable(): void {
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(Deno as any) = 1;
|
(Deno as any) = 1;
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
assert(denoCopy === Deno);
|
assert(denoCopy === Deno);
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(window as any).Deno = 1;
|
(window as any).Deno = 1;
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
assert(denoCopy === Deno);
|
assert(denoCopy === Deno);
|
||||||
try {
|
try {
|
||||||
delete window.Deno;
|
delete window.Deno;
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
assert(denoCopy === Deno);
|
assert(denoCopy === Deno);
|
||||||
|
|
||||||
const { readFile } = Deno;
|
const { readFile } = Deno;
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(Deno as any).readFile = 1;
|
(Deno as any).readFile = 1;
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
assert(readFile === Deno.readFile);
|
assert(readFile === Deno.readFile);
|
||||||
try {
|
try {
|
||||||
delete window.Deno.readFile;
|
delete window.Deno.readFile;
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
assert(readFile === Deno.readFile);
|
assert(readFile === Deno.readFile);
|
||||||
|
|
||||||
const { print } = Deno.core;
|
const { print } = Deno.core;
|
||||||
try {
|
try {
|
||||||
Deno.core.print = 1;
|
Deno.core.print = 1;
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
assert(print === Deno.core.print);
|
assert(print === Deno.core.print);
|
||||||
try {
|
try {
|
||||||
delete Deno.core.print;
|
delete Deno.core.print;
|
||||||
} catch {}
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
assert(print === Deno.core.print);
|
assert(print === Deno.core.print);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,7 @@ unitTest(async function transformStreamStartCalledOnce() {
|
||||||
|
|
||||||
unitTest(function transformStreamReadableTypeThrows() {
|
unitTest(function transformStreamReadableTypeThrows() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
() => new TransformStream({ readableType: "bytes" as any }),
|
() => new TransformStream({ readableType: "bytes" as any }),
|
||||||
RangeError,
|
RangeError,
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -516,7 +516,7 @@ unitTest(function transformStreamReadableTypeThrows() {
|
||||||
|
|
||||||
unitTest(function transformStreamWirtableTypeThrows() {
|
unitTest(function transformStreamWirtableTypeThrows() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
() => new TransformStream({ writableType: "bytes" as any }),
|
() => new TransformStream({ writableType: "bytes" as any }),
|
||||||
RangeError,
|
RangeError,
|
||||||
undefined,
|
undefined,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
reportToConn,
|
reportToConn,
|
||||||
} from "./test_util.ts";
|
} 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];
|
const internalObj = Deno[Deno.internal];
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const reportToConsole = internalObj.reportToConsole as (message: any) => void;
|
const reportToConsole = internalObj.reportToConsole as (message: any) => void;
|
||||||
|
|
Loading…
Reference in a new issue