From 034e2cc02829c9244b32232074c7a48af827a2fb Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Sun, 10 Mar 2019 04:30:38 +1100 Subject: Migrate from tslint to eslint for linting (#1905) --- js/mixins/dom_iterable.ts | 13 ++++++++----- js/mixins/dom_iterable_test.ts | 13 ++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'js/mixins') diff --git a/js/mixins/dom_iterable.ts b/js/mixins/dom_iterable.ts index ae5a030ce..97e8133ec 100644 --- a/js/mixins/dom_iterable.ts +++ b/js/mixins/dom_iterable.ts @@ -1,9 +1,10 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +// eslint-disable-next-line @typescript-eslint/no-unused-vars import { DomIterable } from "../dom_types"; import { window } from "../window"; import { requiredArguments } from "../util"; -// tslint:disable:no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any type Constructor = new (...args: any[]) => T; /** Mixes in a DOM iterable methods into a base class, assumes that there is @@ -12,7 +13,6 @@ type Constructor = new (...args: any[]) => T; * TODO Don't expose DomIterableMixin from "deno" namespace. */ export function DomIterableMixin( - // tslint:disable-next-line:variable-name Base: TBase, dataSymbol: symbol ): TBase & Constructor> { @@ -25,21 +25,23 @@ export function DomIterableMixin( // Symbol.iterator, and some have an Array, which yields V, in this case // [K, V] too as they are arrays of tuples. - // tslint:disable-next-line:variable-name const DomIterable = class extends Base { *entries(): IterableIterator<[K, V]> { + // eslint-disable-next-line @typescript-eslint/no-explicit-any for (const entry of (this as any)[dataSymbol]) { yield entry; } } *keys(): IterableIterator { + // eslint-disable-next-line @typescript-eslint/no-explicit-any for (const [key] of (this as any)[dataSymbol]) { yield key; } } *values(): IterableIterator { + // eslint-disable-next-line @typescript-eslint/no-explicit-any for (const [, value] of (this as any)[dataSymbol]) { yield value; } @@ -47,7 +49,7 @@ export function DomIterableMixin( forEach( callbackfn: (value: V, key: K, parent: this) => void, - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any thisArg?: any ): void { requiredArguments( @@ -56,12 +58,14 @@ export function DomIterableMixin( 1 ); callbackfn = callbackfn.bind(thisArg == null ? window : Object(thisArg)); + // eslint-disable-next-line @typescript-eslint/no-explicit-any for (const [key, value] of (this as any)[dataSymbol]) { callbackfn(value, key, this); } } *[Symbol.iterator](): IterableIterator<[K, V]> { + // eslint-disable-next-line @typescript-eslint/no-explicit-any for (const entry of (this as any)[dataSymbol]) { yield entry; } @@ -76,4 +80,3 @@ export function DomIterableMixin( return DomIterable; } -// tslint:enable:no-any diff --git a/js/mixins/dom_iterable_test.ts b/js/mixins/dom_iterable_test.ts index a0bed7bd3..36e3de678 100644 --- a/js/mixins/dom_iterable_test.ts +++ b/js/mixins/dom_iterable_test.ts @@ -1,6 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { test, assert, assertEquals } from "../test_util.ts"; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function setup() { const dataSymbol = Symbol("data symbol"); class Base { @@ -19,13 +20,12 @@ function setup() { Base, // This is using an internal API we don't want published as types, so having // to cast to any to "trick" TypeScript - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any DomIterable: (Deno as any).DomIterableMixin(Base, dataSymbol) }; } test(function testDomIterable() { - // tslint:disable-next-line:variable-name const { DomIterable, Base } = setup(); const fixture: Array<[string, number]> = [["foo", 1], ["bar", 2]]; @@ -46,7 +46,7 @@ test(function testDomIterable() { result = []; const scope = {}; - function callback(value, key, parent) { + function callback(value, key, parent): void { assertEquals(parent, domIterable); assert(key != null); assert(value != null); @@ -60,14 +60,13 @@ test(function testDomIterable() { }); test(function testDomIterableScope() { - // tslint:disable-next-line:variable-name const { DomIterable } = setup(); const domIterable = new DomIterable([["foo", 1]]); - // tslint:disable-next-line:no-any - function checkScope(thisArg: any, expected: any) { - function callback() { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function checkScope(thisArg: any, expected: any): void { + function callback(): void { assertEquals(this, expected); } domIterable.forEach(callback, thisArg); -- cgit v1.2.3