summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-06-12 09:19:29 -0400
committerGitHub <noreply@github.com>2020-06-12 09:19:29 -0400
commitd0970daacda0b6f6c2077c2f81948536b574bbe9 (patch)
treef116548be832ae6786449dd6f1257865efe38026 /std
parentca1c2ee82207f2ead857ab4aeca48edff16827ae (diff)
make std deno-lint clean (#6240)
Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'std')
-rw-r--r--std/encoding/_yaml/loader/loader.ts2
-rw-r--r--std/encoding/_yaml/utils.ts2
-rw-r--r--std/fmt/printf.ts8
-rw-r--r--std/fs/write_json.ts4
-rw-r--r--std/hash/md5.ts3
-rwxr-xr-xstd/http/file_server.ts4
-rw-r--r--std/http/server.ts8
-rw-r--r--std/log/mod_test.ts4
-rw-r--r--std/node/_util/_util_callbackify_test.ts14
-rw-r--r--std/node/_util/_util_promisify.ts2
-rw-r--r--std/node/_utils.ts8
-rw-r--r--std/node/events.ts4
-rw-r--r--std/node/module.ts12
-rw-r--r--std/path/parse_format_test.ts5
-rw-r--r--std/textproto/mod.ts4
-rw-r--r--std/ws/mod.ts3
16 files changed, 57 insertions, 30 deletions
diff --git a/std/encoding/_yaml/loader/loader.ts b/std/encoding/_yaml/loader/loader.ts
index f0d535624..39954c280 100644
--- a/std/encoding/_yaml/loader/loader.ts
+++ b/std/encoding/_yaml/loader/loader.ts
@@ -1417,7 +1417,7 @@ function readAlias(state: LoaderState): boolean {
const alias = state.input.slice(_position, state.position);
if (
typeof state.anchorMap !== "undefined" &&
- !state.anchorMap.hasOwnProperty(alias)
+ !Object.prototype.hasOwnProperty.call(state.anchorMap, alias)
) {
return throwError(state, `unidentified alias "${alias}"`);
}
diff --git a/std/encoding/_yaml/utils.ts b/std/encoding/_yaml/utils.ts
index 4630a45a2..e009ae3cf 100644
--- a/std/encoding/_yaml/utils.ts
+++ b/std/encoding/_yaml/utils.ts
@@ -3,7 +3,7 @@
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Any = any;
export function isNothing(subject: unknown): subject is never {
diff --git a/std/fmt/printf.ts b/std/fmt/printf.ts
index 8c2f8d034..bf5feaaed 100644
--- a/std/fmt/printf.ts
+++ b/std/fmt/printf.ts
@@ -221,7 +221,7 @@ class Printf {
flags.width += val;
} // switch c
break;
- case State.PRECISION:
+ case State.PRECISION: {
if (c === "*") {
this.handleWidthOrPrecisionRef(WorP.PRECISION);
break;
@@ -236,6 +236,7 @@ class Printf {
flags.precision *= 10;
flags.precision += val;
break;
+ }
default:
throw new Error("can't be here. bug.");
} // switch state
@@ -627,8 +628,7 @@ class Printf {
switch (typeof val) {
case "number":
return this.fmtNumber(val as number, 16, upper);
- break;
- case "string":
+ case "string": {
const sharp = this.flags.sharp && val.length !== 0;
let hex = sharp ? "0x" : "";
const prec = this.flags.precision;
@@ -647,7 +647,7 @@ class Printf {
hex = hex.toUpperCase();
}
return this.pad(hex);
- break;
+ }
default:
throw new Error(
"currently only number and string are implemented for hex"
diff --git a/std/fs/write_json.ts b/std/fs/write_json.ts
index e382fa306..28eb80d44 100644
--- a/std/fs/write_json.ts
+++ b/std/fs/write_json.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-/* eslint-disable @typescript-eslint/no-explicit-any */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Replacer = (key: string, value: any) => any;
export interface WriteJsonOptions {
@@ -10,6 +10,7 @@ export interface WriteJsonOptions {
/* Writes an object to a JSON file. */
export async function writeJson(
filePath: string,
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
object: any,
options: WriteJsonOptions = {}
): Promise<void> {
@@ -32,6 +33,7 @@ export async function writeJson(
/* Writes an object to a JSON file. */
export function writeJsonSync(
filePath: string,
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
object: any,
options: WriteJsonOptions = {}
): void {
diff --git a/std/hash/md5.ts b/std/hash/md5.ts
index 9415b5f80..f7e55d961 100644
--- a/std/hash/md5.ts
+++ b/std/hash/md5.ts
@@ -235,13 +235,14 @@ export class Md5 {
switch (format) {
case "hex":
return hex.encodeToString(new Uint8Array(hash));
- case "base64":
+ case "base64": {
const data = new Uint8Array(hash);
let dataString = "";
for (let i = 0; i < data.length; ++i) {
dataString += String.fromCharCode(data[i]);
}
return window.btoa(dataString);
+ }
default:
throw new Error("md5: invalid format");
}
diff --git a/std/http/file_server.ts b/std/http/file_server.ts
index 66babfd57..d9ed56236 100755
--- a/std/http/file_server.ts
+++ b/std/http/file_server.ts
@@ -135,7 +135,9 @@ async function serveDir(
let fileInfo = null;
try {
fileInfo = await stat(filePath);
- } catch (e) {}
+ } catch (e) {
+ // Pass
+ }
listEntry.push({
mode: modeToString(entry.isDirectory, fileInfo?.mode ?? null),
size: entry.isFile ? fileLenToString(fileInfo?.size ?? 0) : "",
diff --git a/std/http/server.ts b/std/http/server.ts
index 18bfc4731..d2736cb43 100644
--- a/std/http/server.ts
+++ b/std/http/server.ts
@@ -90,7 +90,9 @@ export class ServerRequest {
try {
// Eagerly close on error.
this.conn.close();
- } catch {}
+ } catch {
+ // Pass
+ }
err = e;
}
// Signal that this request has been processed and the next pipelined
@@ -108,7 +110,9 @@ export class ServerRequest {
// Consume unread body
const body = this.body;
const buf = new Uint8Array(1024);
- while ((await body.read(buf)) !== null) {}
+ while ((await body.read(buf)) !== null) {
+ // Pass
+ }
this.finalized = true;
}
}
diff --git a/std/log/mod_test.ts b/std/log/mod_test.ts
index ceedcc858..30576011b 100644
--- a/std/log/mod_test.ts
+++ b/std/log/mod_test.ts
@@ -9,7 +9,9 @@ try {
// Need to initialize it here
// otherwise it will be already initialized on Deno.test
logger = getLogger();
-} catch {}
+} catch {
+ // Pass
+}
test("logger is initialized", function (): void {
assert(logger instanceof Logger);
diff --git a/std/node/_util/_util_callbackify_test.ts b/std/node/_util/_util_callbackify_test.ts
index c68a2ed50..630e4d0e7 100644
--- a/std/node/_util/_util_callbackify_test.ts
+++ b/std/node/_util/_util_callbackify_test.ts
@@ -21,8 +21,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-/* eslint-disable @typescript-eslint/no-explicit-any */
-
const { test } = Deno;
import { assert, assertStrictEquals } from "../../testing/asserts.ts";
import { callbackify } from "./_util_callbackify.ts";
@@ -107,8 +105,10 @@ test("callbackify passes the resolution value as the second argument to the call
});
});
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
function thenableFn(): PromiseLike<any> {
return {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
then(onfulfilled): PromiseLike<any> {
assert(onfulfilled);
onfulfilled(value);
@@ -146,7 +146,9 @@ test("callbackify passes the rejection value as the first argument to the callba
if (err instanceof Error) {
if ("reason" in err) {
assert(!value);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).code, "ERR_FALSY_VALUE_REJECTION");
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).reason, value);
} else {
assertStrictEquals(String(value).endsWith(err.message), true);
@@ -177,7 +179,9 @@ test("callbackify passes the rejection value as the first argument to the callba
if (err instanceof Error) {
if ("reason" in err) {
assert(!value);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).code, "ERR_FALSY_VALUE_REJECTION");
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).reason, value);
} else {
assertStrictEquals(String(value).endsWith(err.message), true);
@@ -206,7 +210,9 @@ test("callbackify passes the rejection value as the first argument to the callba
if (err instanceof Error) {
if ("reason" in err) {
assert(!value);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).code, "ERR_FALSY_VALUE_REJECTION");
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).reason, value);
} else {
assertStrictEquals(String(value).endsWith(err.message), true);
@@ -322,10 +328,12 @@ test("callbackify preserves the `this` binding", async () => {
test("callbackify throws with non-function inputs", () => {
["foo", null, undefined, false, 0, {}, Symbol(), []].forEach((value) => {
try {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
callbackify(value as any);
throw Error("We should never reach this error");
} catch (err) {
assert(err instanceof TypeError);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).code, "ERR_INVALID_ARG_TYPE");
assertStrictEquals(err.name, "TypeError");
assertStrictEquals(
@@ -342,6 +350,7 @@ test("callbackify returns a function that throws if the last argument is not a f
return 42;
}
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const cb = callbackify(asyncFn) as any;
const args: unknown[] = [];
@@ -353,6 +362,7 @@ test("callbackify returns a function that throws if the last argument is not a f
throw Error("We should never reach this error");
} catch (err) {
assert(err instanceof TypeError);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).code, "ERR_INVALID_ARG_TYPE");
assertStrictEquals(err.name, "TypeError");
assertStrictEquals(
diff --git a/std/node/_util/_util_promisify.ts b/std/node/_util/_util_promisify.ts
index d7ca55be8..e3cc36a0c 100644
--- a/std/node/_util/_util_promisify.ts
+++ b/std/node/_util/_util_promisify.ts
@@ -69,7 +69,7 @@ export function promisify(original: Function): Function {
function fn(...args: unknown[]): Promise<unknown> {
return new Promise((resolve, reject) => {
- // @ts-ignore
+ // @ts-ignore: 'this' implicitly has type 'any' because it does not have a type annotation
original.call(this, ...args, (err: Error, ...values: unknown[]) => {
if (err) {
return reject(err);
diff --git a/std/node/_utils.ts b/std/node/_utils.ts
index b8c4fa00e..463d4e67c 100644
--- a/std/node/_utils.ts
+++ b/std/node/_utils.ts
@@ -16,10 +16,10 @@ export type MaybeDefined<T> = T | undefined;
export type MaybeEmpty<T> = T | null | undefined;
export function intoCallbackAPI<T>(
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
func: (...args: any[]) => Promise<T>,
cb: MaybeEmpty<(err: MaybeNull<Error>, value: MaybeEmpty<T>) => void>,
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
...args: any[]
): void {
func(...args)
@@ -28,11 +28,11 @@ export function intoCallbackAPI<T>(
}
export function intoCallbackAPIWithIntercept<T1, T2>(
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
func: (...args: any[]) => Promise<T1>,
interceptor: (v: T1) => T2,
cb: MaybeEmpty<(err: MaybeNull<Error>, value: MaybeEmpty<T2>) => void>,
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
...args: any[]
): void {
func(...args)
diff --git a/std/node/events.ts b/std/node/events.ts
index fee715f0c..8d6e90abd 100644
--- a/std/node/events.ts
+++ b/std/node/events.ts
@@ -226,7 +226,8 @@ export default class EventEmitter {
rawListener: Function;
context: EventEmitter;
},
- ...args: any[] // eslint-disable-line @typescript-eslint/no-explicit-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ ...args: any[]
): void {
this.context.removeListener(this.eventName, this.rawListener);
this.listener.apply(this.context, args);
@@ -434,7 +435,6 @@ export function on(
const unconsumedEventValues: any[] = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const unconsumedPromises: any[] = [];
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
let error: Error | null = null;
let finished = false;
diff --git a/std/node/module.ts b/std/node/module.ts
index daa01d2b2..55c5f2d32 100644
--- a/std/node/module.ts
+++ b/std/node/module.ts
@@ -659,7 +659,9 @@ function readPackage(requestPath: string): PackageInfo | null {
json = new TextDecoder().decode(
Deno.readFileSync(path.toNamespacedPath(jsonPath))
);
- } catch {}
+ } catch {
+ // pass
+ }
if (json === undefined) {
packageJsonCache.set(jsonPath, null);
@@ -839,7 +841,7 @@ function applyExports(basePath: string, expansion: string): string {
}
if (typeof pkgExports === "object") {
- if (pkgExports.hasOwnProperty(mappingKey)) {
+ if (Object.prototype.hasOwnProperty.call(pkgExports, mappingKey)) {
const mapping = pkgExports[mappingKey];
return resolveExportsTarget(
pathToFileURL(basePath + "/"),
@@ -910,7 +912,6 @@ function resolveExports(
return path.resolve(nmPath, request);
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
function resolveExportsTarget(
pkgPath: URL,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -959,7 +960,7 @@ function resolveExportsTarget(
}
} else if (typeof target === "object" && target !== null) {
// removed experimentalConditionalExports
- if (target.hasOwnProperty("default")) {
+ if (Object.prototype.hasOwnProperty.call(target, "default")) {
try {
return resolveExportsTarget(
pkgPath,
@@ -1012,7 +1013,7 @@ const CircularRequirePrototypeWarningProxy = new Proxy(
},
getOwnPropertyDescriptor(target, prop): PropertyDescriptor | undefined {
- if (target.hasOwnProperty(prop)) {
+ if (Object.prototype.hasOwnProperty.call(target, prop)) {
return Object.getOwnPropertyDescriptor(target, prop);
}
emitCircularRequireWarning(prop);
@@ -1114,7 +1115,6 @@ interface RequireResolveFunction extends RequireResolve {
}
interface RequireFunction extends Require {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
resolve: RequireResolveFunction;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
extensions: { [key: string]: (module: Module, filename: string) => any };
diff --git a/std/path/parse_format_test.ts b/std/path/parse_format_test.ts
index 2bd510551..bc58679cf 100644
--- a/std/path/parse_format_test.ts
+++ b/std/path/parse_format_test.ts
@@ -1,6 +1,6 @@
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
-/* eslint-disable @typescript-eslint/no-explicit-any */
+
// TODO(kt3k): fix any types in this file
const { test } = Deno;
@@ -80,6 +80,7 @@ const unixSpecialCaseFormatTests = [
[{}, ""],
];
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
function checkParseFormat(path: any, paths: any): void {
paths.forEach(function (p: Array<Record<string, unknown>>) {
const element = p[0];
@@ -96,6 +97,7 @@ function checkParseFormat(path: any, paths: any): void {
});
}
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
function checkSpecialCaseParseFormat(path: any, testCases: any): void {
testCases.forEach(function (testCase: Array<Record<string, unknown>>) {
const element = testCase[0];
@@ -107,6 +109,7 @@ function checkSpecialCaseParseFormat(path: any, testCases: any): void {
});
}
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
function checkFormat(path: any, testCases: unknown[][]): void {
testCases.forEach(function (testCase) {
assertEquals(path.format(testCase[0]), testCase[1]);
diff --git a/std/textproto/mod.ts b/std/textproto/mod.ts
index 48bbed8bf..e5645a9ed 100644
--- a/std/textproto/mod.ts
+++ b/std/textproto/mod.ts
@@ -114,7 +114,9 @@ export class TextProtoReader {
// example: "Audio Mode" => invalid due to space in the key
try {
m.append(key, value);
- } catch {}
+ } catch {
+ // Pass
+ }
}
}
diff --git a/std/ws/mod.ts b/std/ws/mod.ts
index f58828aea..4d3f79f74 100644
--- a/std/ws/mod.ts
+++ b/std/ws/mod.ts
@@ -262,7 +262,7 @@ class WebSocketImpl implements WebSocket {
payloadsLength = 0;
}
break;
- case OpCode.Close:
+ case OpCode.Close: {
// [0x12, 0x34] -> 0x1234
const code = (frame.payload[0] << 8) | frame.payload[1];
const reason = decode(
@@ -271,6 +271,7 @@ class WebSocketImpl implements WebSocket {
await this.close(code, reason);
yield { code, reason };
return;
+ }
case OpCode.Ping:
await this.enqueue({
opcode: OpCode.Pong,