Skip to content

Commit

Permalink
refactor: fix codes to pass no-unused-vars lint (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna authored Mar 2, 2021
1 parent 692fc6f commit b134d54
Show file tree
Hide file tree
Showing 25 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion encoding/_yaml/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function compileList(
result.push(currentType);
}

return result.filter((type, index): unknown => !exclude.includes(index));
return result.filter((_type, index): unknown => !exclude.includes(index));
}

export type TypeMap = { [k in KindType | "fallback"]: ArrayObject<Type> };
Expand Down
2 changes: 1 addition & 1 deletion examples/chat/server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function startServer(): Promise<
const r = new TextProtoReader(new BufReader(server.stdout));
const s = await r.readLine();
assert(s !== null && s.includes("chat server starting"));
} catch (err) {
} catch {
server.stdout.close();
server.close();
}
Expand Down
2 changes: 1 addition & 1 deletion fmt/printf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class Printf {
let s = "";
try {
s = String.fromCodePoint(n);
} catch (RangeError) {
} catch {
s = UNICODE_REPLACEMENT_CHARACTER;
}
return this.pad(s);
Expand Down
2 changes: 1 addition & 1 deletion http/cookie_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Deno.test({
secure: true,
maxAge: 0,
});
} catch (e) {
} catch {
error = true;
}
assert(error);
Expand Down
2 changes: 1 addition & 1 deletion http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async function serveDir(
return res;
}

function serveFallback(req: ServerRequest, e: Error): Promise<Response> {
function serveFallback(_req: ServerRequest, e: Error): Promise<Response> {
if (e instanceof URIError) {
return Promise.resolve({
status: 400,
Expand Down
1 change: 0 additions & 1 deletion http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import {
assert,
assertEquals,
assertNotEquals,
assertStringIncludes,
} from "../testing/asserts.ts";
import { BufReader } from "../io/bufio.ts";
Expand Down
6 changes: 3 additions & 3 deletions http/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class Server implements AsyncIterable<ServerRequest> {
status: 400,
body: new TextEncoder().encode(`${error.message}\r\n\r\n`),
});
} catch (error) {
} catch {
// The connection is broken.
}
}
Expand All @@ -187,7 +187,7 @@ export class Server implements AsyncIterable<ServerRequest> {
try {
// Consume unread body and trailers if receiver didn't consume those data
await request.finalize();
} catch (error) {
} catch {
// Invalid data was received or the connection was closed.
break;
}
Expand All @@ -196,7 +196,7 @@ export class Server implements AsyncIterable<ServerRequest> {
this.untrackConnection(conn);
try {
conn.close();
} catch (e) {
} catch {
// might have been already closed
}
}
Expand Down
6 changes: 1 addition & 5 deletions node/_crypto/pbkdf2_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import {
pbkdf2,
pbkdf2Sync,
} from "./pbkdf2.ts";
import {
assert,
assertEquals,
assertStringIncludes,
} from "../../testing/asserts.ts";
import { assert, assertEquals } from "../../testing/asserts.ts";
import { assertCallbackErrorUncaught } from "../_utils.ts";

type Pbkdf2Fixture = {
Expand Down
1 change: 0 additions & 1 deletion node/_crypto/randomBytes_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
assert,
assertEquals,
assertStringIncludes,
assertThrows,
assertThrowsAsync,
} from "../../testing/asserts.ts";
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export function access(
// TODO(bartlomieju) 'path' can also be a Buffer. Neither of these polyfills
// is available yet. See https://github.com/denoland/deno/issues/3403
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function accessSync(path: string | URL, mode?: number): void {
export function accessSync(_path: string | URL, _mode?: number): void {
notImplemented("Not yet available");
}
2 changes: 1 addition & 1 deletion node/_fs/_fs_dir_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Deno.test({
const firstRead: Dirent | null = await dir.read();
const secondRead: Dirent | null = await dir.read(
// deno-lint-ignore no-explicit-any
(err: any, secondResult: Dirent) => {
(_err: any, secondResult: Dirent) => {
assert(
secondResult.name === "bar.txt" ||
secondResult.name === "foo.txt",
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_mkdtemp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function parseEncoding(
if (encoding) {
try {
new TextDecoder(encoding);
} catch (error) {
} catch {
throw new ERR_INVALID_OPT_VALUE_ENCODING(encoding);
}
}
Expand Down
4 changes: 2 additions & 2 deletions node/_fs/_fs_readdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function readdir(
if (options?.encoding) {
try {
new TextDecoder(options.encoding);
} catch (error) {
} catch {
throw new Error(
`TypeError [ERR_INVALID_OPT_VALUE_ENCODING]: The value "${options.encoding}" is invalid for option "encoding"`,
);
Expand Down Expand Up @@ -100,7 +100,7 @@ export function readdirSync(
if (options?.encoding) {
try {
new TextDecoder(options.encoding);
} catch (error) {
} catch {
throw new Error(
`TypeError [ERR_INVALID_OPT_VALUE_ENCODING]: The value "${options.encoding}" is invalid for option "encoding"`,
);
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_watch_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { watch } from "./_fs_watch.ts";
import { assertEquals, fail } from "../../testing/asserts.ts";
import { assertEquals } from "../../testing/asserts.ts";

function wait(time: number) {
return new Promise((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion node/_stream/duplex_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function endReadableNT(state: ReadableState, stream: Duplex) {
}
}

function endWritableNT(state: ReadableState, stream: Duplex) {
function endWritableNT(_state: ReadableState, stream: Duplex) {
const writable = stream.writable &&
!stream.writableEnded &&
!stream.destroyed;
Expand Down
2 changes: 1 addition & 1 deletion node/_util/_util_callbackify_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Deno.test(

const thenableFn = (): PromiseLike<never> => {
return {
then(onfulfilled, onrejected): PromiseLike<never> {
then(_onfulfilled, onrejected): PromiseLike<never> {
assert(onrejected);
onrejected(value);
return this;
Expand Down
1 change: 0 additions & 1 deletion node/assert_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import {
assert as denoAssert,
assertEquals,
assertMatch,
assertNotEquals,
Expand Down
2 changes: 1 addition & 1 deletion node/assertion_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export class AssertionError extends Error {
return `${this.name} [${this.code}]: ${this.message}`;
}

[inspect.custom](recurseTimes: number, ctx: Record<string, unknown>) {
[inspect.custom](_recurseTimes: number, ctx: Record<string, unknown>) {
// Long strings should not be fully inspected.
const tmpActual = this.actual;
const tmpExpected = this.expected;
Expand Down
2 changes: 1 addition & 1 deletion node/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { encodeToString as encodeToHexString } from "../encoding/hex.ts";
*/
export class Hash extends Transform {
public hash: Hasher;
constructor(algorithm: SupportedAlgorithm, opts?: TransformOptions) {
constructor(algorithm: SupportedAlgorithm, _opts?: TransformOptions) {
super({
transform(chunk: string, _encoding: string, callback: () => void): void {
hash.update(chunk);
Expand Down
2 changes: 1 addition & 1 deletion node/events_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ Deno.test("Elements that extend EventEmitter listener alias don't end up in a de
const x = new X();
try {
x.on("x", () => {});
} catch (e) {
} catch {
fail();
}
});
1 change: 1 addition & 0 deletions node/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export function uptime(): number {

/** Not yet implemented */
export function userInfo(
// deno-lint-ignore no-unused-vars
options: UserInfoOptions = { encoding: "utf-8" },
): UserInfo {
notImplemented(SEE_GITHUB_ISSUE);
Expand Down
8 changes: 4 additions & 4 deletions testing/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export function assertEquals(
);
const diffMsg = buildMessage(diffResult).join("\n");
message = `Values are not equal:\n${diffMsg}`;
} catch (e) {
} catch {
message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`;
}
if (msg) {
Expand Down Expand Up @@ -247,12 +247,12 @@ export function assertNotEquals(
let expectedString: string;
try {
actualString = String(actual);
} catch (e) {
} catch {
actualString = "[Cannot display]";
}
try {
expectedString = String(expected);
} catch (e) {
} catch {
expectedString = "[Cannot display]";
}
if (!msg) {
Expand Down Expand Up @@ -312,7 +312,7 @@ export function assertStrictEquals(
);
const diffMsg = buildMessage(diffResult).join("\n");
message = `Values are not strictly equal:\n${diffMsg}`;
} catch (e) {
} catch {
message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`;
}
}
Expand Down
1 change: 1 addition & 0 deletions wasi/snapshot_preview1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-unused-vars

import { relative, resolve } from "../path/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion wasi/snapshot_preview1_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import Context from "./snapshot_preview1.ts";
import { assert, assertEquals, assertThrows } from "../testing/asserts.ts";
import { assertEquals, assertThrows } from "../testing/asserts.ts";
import { copy } from "../fs/mod.ts";
import * as path from "../path/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion ws/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class WebSocketImpl implements WebSocket {
let frame: WebSocketFrame;
try {
frame = await readFrame(this.bufReader);
} catch (e) {
} catch {
this.ensureSocketClosed();
break;
}
Expand Down

0 comments on commit b134d54

Please sign in to comment.