mirror of
https://github.com/denoland/deno.git
synced 2025-01-22 06:09:25 -05:00
make std deno-lint clean (#6240)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
ca1c2ee822
commit
d0970daacd
17 changed files with 70 additions and 30 deletions
|
@ -31,6 +31,19 @@ fn std_tests() {
|
|||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn std_lint() {
|
||||
let status = util::deno_cmd()
|
||||
.arg("lint")
|
||||
.arg("--unstable")
|
||||
.arg(util::root_path().join("std"))
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn x_deno_warning() {
|
||||
let g = util::http_server();
|
||||
|
|
|
@ -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}"`);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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) : "",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue