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

@@ -4,8 +4,7 @@
* 1. The css library was built for node.js which does not have tree-shaking supports.
* 2. Rewrites into typescript give us a better type interface.
*/
/* tslint:disable no-conditional-assignment interface-name no-shadowed-variable */
/* eslint-disable tsdoc/syntax */
export interface ParserOptions {
/** Silently fail on parse errors */
@@ -288,7 +287,7 @@ export function parse(css: string, options: ParserOptions = {}) {
function error(msg: string) {
const err = new Error(
options.source + ':' + lineno + ':' + column + ': ' + msg,
`${options.source || ''}:${lineno}:${column}: ${msg}`,
) as ParserError;
err.reason = msg;
err.filename = options.source;
@@ -457,6 +456,7 @@ export function parse(css: string, options: ParserOptions = {}) {
const pos = position();
// prop
// eslint-disable-next-line no-useless-escape
const propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
if (!propMatch) {
return;
@@ -469,6 +469,7 @@ export function parse(css: string, options: ParserOptions = {}) {
}
// val
// eslint-disable-next-line no-useless-escape
const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
const ret = pos({
@@ -889,6 +890,7 @@ function addParent(obj: Stylesheet, parent?: Stylesheet) {
const value = obj[k as keyof Stylesheet];
if (Array.isArray(value)) {
value.forEach((v) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
addParent(v, childParent);
});
} else if (value && typeof value === 'object') {