From e2c1778bb8105d56e64d6b8abf1e4e794a8d5b72 Mon Sep 17 00:00:00 2001 From: Westin Wrzesinski Date: Tue, 22 Nov 2022 20:24:14 -0600 Subject: [PATCH] fix: one file left to lint --- src/dom.ts | 41 ++++++++++++++++++++++------------------- src/global.ts | 5 ++--- src/test.ts | 6 ++++++ src/types.ts | 1 + 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/dom.ts b/src/dom.ts index cb36b29..a869fb5 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -567,11 +567,11 @@ export function popup( }; } - const params = Object.keys(options) // eslint-disable-next-line array-callback-return + const params = Object.keys(options) .map((key) => { - // @ts-expect-error + // @ts-expect-error cant see index for some reason if (options[key] !== null && options[key] !== undefined) { - // @ts-expect-error + // @ts-expect-error cant see index for some reason return `${key}=${stringify(options[key])}`; } }) @@ -582,6 +582,7 @@ export function popup( try { // @ts-expect-error window.open can be null but we didn't account for that + // eslint-disable-next-line security/detect-non-literal-fs-filename win = window.open(url, name, params); } catch (err) { throw new PopupOpenError( @@ -649,9 +650,9 @@ export function setStyle( styleText: string, doc: Document = window.document ): void { - // @ts-expect-error + // @ts-expect-error styleSheet does not exist on HTMLElement if (el.styleSheet) { - // @ts-expect-error + // @ts-expect-error styleSheet does not exist on HTMLElement el.styleSheet.cssText = styleText; } else { el.appendChild(doc.createTextNode(styleText)); @@ -755,14 +756,14 @@ export function createElement( if (options.html) { if (tag === "iframe") { - // @ts-expect-error + // @ts-expect-error contentWindow does not exist on HTMLElement if (!container || !element.contentWindow) { throw new Error( `Iframe html can not be written unless container provided and iframe in DOM` ); } - // @ts-expect-error + // @ts-expect-error contentWindow does not exist on HTMLElement writeToWindow(element.contentWindow, options.html); } else { element.innerHTML = options.html; @@ -806,20 +807,21 @@ export function iframe( border: "none", ...style, }; + // @ts-expect-error - createElement takes 3 args not 2 const frame = createElement("iframe", { attributes: newAttributes, style: newStyle, html: options.html, class: options.class, - }); + }) as HTMLIFrameElement; + const isIE = /MSIE|Edge/i.exec(window.navigator.userAgent); if (!frame.hasAttribute("id")) { frame.setAttribute("id", uniqueID()); } - // @ts-expect-error Argument of type 'HTMLElement' is not assignable to parameter of type 'HTMLIFrameElement'. void awaitFrameLoad(frame); if (container) { @@ -831,7 +833,6 @@ export function iframe( frame.setAttribute("src", options.url || "about:blank"); } - // @ts-expect-error return frame; } @@ -875,12 +876,12 @@ export function setVendorCSS( name: string, value: string ): void { - // @ts-expect-error + // @ts-expect-error indexer as string element.style[name] = value; const capitalizedName = capitalizeFirstLetter(name); for (const prefix of VENDOR_PREFIXES) { - // @ts-expect-error + // @ts-expect-error indexer as string element.style[`${prefix}${capitalizedName}`] = value; } } @@ -931,7 +932,7 @@ export function animate( } startEvent = bindEvents(el, ANIMATION_START_EVENTS, (event) => { - // @ts-expect-error + // @ts-expect-error animationName does not exist on event if (event.target !== el || event.animationName !== name) { return; } @@ -946,7 +947,7 @@ export function animate( }, timeout); }); endEvent = bindEvents(el, ANIMATION_END_EVENTS, (event) => { - // @ts-expect-error + // @ts-expect-error animationName does not exist on event if (event.target !== el || event.animationName !== name) { return; } @@ -954,13 +955,13 @@ export function animate( cleanUp(); if ( - // @ts-expect-error + // @ts-expect-error animationName does not exist on event typeof event.animationName === "string" && - // @ts-expect-error + // @ts-expect-error animationName does not exist on event event.animationName !== name ) { reject( - // @ts-expect-error + // @ts-expect-error animationName does not exist on event `Expected animation name to be ${name}, found ${event.animationName}` ); return; @@ -1272,6 +1273,8 @@ export function isShadowElement(element: Node): boolean { element = element.parentNode; } + // 'element' will evaluate to '[object Object]' when stringified. + // eslint-disable-next-line @typescript-eslint/no-base-to-string return element.toString() === "[object ShadowRoot]"; } @@ -1290,9 +1293,9 @@ export function getShadowHost( ): HTMLElement | undefined | undefined { const shadowRoot = getShadowRoot(element); - // @ts-expect-error + // @ts-expect-error host does not exist on node if (shadowRoot && shadowRoot.host) { - // @ts-expect-error + // @ts-expect-error host does not exist on node return shadowRoot.host; } } diff --git a/src/global.ts b/src/global.ts index d88eec1..10c9780 100644 --- a/src/global.ts +++ b/src/global.ts @@ -7,14 +7,13 @@ export function getGlobalNameSpace>({ name: string; version?: string; }): { - get: (arg0: string, defValue?: T) => T; + get: (arg0: string, defValue?: T) => T | {}; } { const global = getGlobal(); const globalKey = `__${name}__${version}_global__`; const namespace = (global[globalKey] = global[globalKey] || {}); return { - get: (key: string, defValue?: T): T => { - // @ts-expect-error + get: (key: string, defValue?: T | {}): T | {} => { defValue = defValue || {}; const item = (namespace[key] = namespace[key] || defValue); return item; diff --git a/src/test.ts b/src/test.ts index ae6cb36..7be18c2 100644 --- a/src/test.ts +++ b/src/test.ts @@ -1,3 +1,5 @@ +/* eslint @typescript-eslint/ban-ts-comment: 0 */ + import { ZalgoPromise } from "@krakenjs/zalgo-promise"; import { noop, tryCatch, removeFromArray } from "./util"; @@ -70,6 +72,8 @@ export function wrapPromise( name, promise: ZalgoPromise.asyncReject(error), }); + // expected an error to be thrown + // eslint-disable-next-line @typescript-eslint/no-throw-literal throw error; } @@ -114,6 +118,8 @@ export function wrapPromise( const { result, error } = tryCatch(() => handler.call(this, ...args)); if (error) { + // expected an error to be thrown + // eslint-disable-next-line @typescript-eslint/no-throw-literal throw error; } diff --git a/src/types.ts b/src/types.ts index f6cd2b7..5e864a9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,6 +8,7 @@ export type JSONPrimitive = string | boolean | number; // TODO: need a fix // @ts-expect-error circularly references self +// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents type JSONValue = string | number | boolean | JSONObject | JSONArray; // TODO: need a fix