Skip to content

Commit

Permalink
fix: one file left to lint
Browse files Browse the repository at this point in the history
  • Loading branch information
westeezy committed Nov 23, 2022
1 parent f53d4e1 commit e2c1778
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
41 changes: 22 additions & 19 deletions src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])}`;
}
})
Expand All @@ -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(
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -831,7 +833,6 @@ export function iframe(
frame.setAttribute("src", options.url || "about:blank");
}

// @ts-expect-error
return frame;
}

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -946,21 +947,21 @@ 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;
}

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;
Expand Down Expand Up @@ -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]";
}

Expand All @@ -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;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ export function getGlobalNameSpace<T extends Record<string, any>>({
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;
Expand Down
6 changes: 6 additions & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint @typescript-eslint/ban-ts-comment: 0 */

import { ZalgoPromise } from "@krakenjs/zalgo-promise";

import { noop, tryCatch, removeFromArray } from "./util";
Expand Down Expand Up @@ -70,6 +72,8 @@ export function wrapPromise<T>(
name,
promise: ZalgoPromise.asyncReject(error),
});
// expected an error to be thrown
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw error;
}

Expand Down Expand Up @@ -114,6 +118,8 @@ export function wrapPromise<T>(
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;
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e2c1778

Please sign in to comment.