refactor: eliminate eslint errors (#920)

* refactor: eliminate eslint errors as many as I can

* refactor: fix more eslint errors in the record module

* LINT: fix @typescript-eslint/unbound-method

* LINT: fix all eslint errors in source code

* LINT: fix as many eslint warnings as possible

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
This commit is contained in:
Yun Feng
2022-07-10 17:49:20 +10:00
committed by GitHub
parent 15cb0b8cd3
commit 83394c3db4
44 changed files with 524 additions and 374 deletions

View File

@@ -102,7 +102,14 @@ export function absoluteToStylesheet(
): string {
return (cssText || '').replace(
URL_IN_CSS_REF,
(origin, quote1, path1, quote2, path2, path3) => {
(
origin: string,
quote1: string,
path1: string,
quote2: string,
path2: string,
path3: string,
) => {
const filePath = path1 || path2 || path3;
const maybeQuote = quote1 || quote2 || '';
if (!filePath) {
@@ -136,7 +143,9 @@ export function absoluteToStylesheet(
);
}
// eslint-disable-next-line no-control-regex
const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/; // Don't use \s, to avoid matching non-breaking space
// eslint-disable-next-line no-control-regex
const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
function getAbsoluteSrcsetString(doc: Document, attributeValue: string) {
/*
@@ -165,6 +174,7 @@ function getAbsoluteSrcsetString(doc: Document, attributeValue: string) {
}
const output = [];
// eslint-disable-next-line no-constant-condition
while (true) {
collectCharacters(SRCSET_COMMAS_OR_SPACES);
if (pos >= attributeValue.length) {
@@ -182,6 +192,7 @@ function getAbsoluteSrcsetString(doc: Document, attributeValue: string) {
let descriptorsStr = '';
url = absoluteToDoc(doc, url);
let inParens = false;
// eslint-disable-next-line no-constant-condition
while (true) {
const c = attributeValue.charAt(pos);
if (c === '') {
@@ -554,7 +565,7 @@ function serializeTextNode(
}
} catch (err) {
console.warn(
`Cannot get CSS styles from text's parentNode. Error: ${err}`,
`Cannot get CSS styles from text's parentNode. Error: ${err as string}`,
n,
);
}
@@ -740,7 +751,7 @@ function serializeElementNode(
);
} catch (err) {
console.warn(
`Cannot inline img src=${image.currentSrc}! Error: ${err}`,
`Cannot inline img src=${image.currentSrc}! Error: ${err as string}`,
);
}
oldValue