Fix lint issues
continuous-integration/drone Build is passing Details

This commit is contained in:
Hamcha 2022-05-10 12:37:34 +02:00
parent db35e9640f
commit 2ce3df0332
Signed by: Hamcha
GPG Key ID: 1669C533B8CF6D89
4 changed files with 27 additions and 22 deletions

View File

@ -19,7 +19,9 @@ module.exports = {
"no-param-reassign": "off", "no-param-reassign": "off",
"no-alert": "off", "no-alert": "off",
"no-console": "off", "no-console": "off",
"no-shadow": "off",
"func-names": "off", "func-names": "off",
"default-param-last": "off",
"dot-notation": ["error", { allowPattern: "^[A-Z][a-z]+$" }], "dot-notation": ["error", { allowPattern: "^[A-Z][a-z]+$" }],
"@typescript-eslint/ban-ts-comment": [ "@typescript-eslint/ban-ts-comment": [
"error", "error",
@ -27,5 +29,7 @@ module.exports = {
"ts-expect-error": "allow-with-description", "ts-expect-error": "allow-with-description",
}, },
], ],
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/default-param-last": ["error"],
}, },
}; };

View File

@ -8,6 +8,7 @@ interface CacheEntry<T> {
export class Store { export class Store {
readonly dbp: Promise<IDBDatabase>; readonly dbp: Promise<IDBDatabase>;
// eslint-disable-next-line default-param-last
constructor(dbName = "tg-cache", readonly storeName = "keyval") { constructor(dbName = "tg-cache", readonly storeName = "keyval") {
this.dbp = new Promise((resolve, reject) => { this.dbp = new Promise((resolve, reject) => {
const openreq = indexedDB.open(dbName, 1); const openreq = indexedDB.open(dbName, 1);
@ -51,8 +52,8 @@ export function get<Type>(
): Promise<CacheEntry<Type>> { ): Promise<CacheEntry<Type>> {
let req: IDBRequest; let req: IDBRequest;
return store return store
.withIDBStore("readonly", (store) => { .withIDBStore("readonly", (idbstore) => {
req = store.get(key); req = idbstore.get(key);
}) })
.then(() => req.result); .then(() => req.result);
} }
@ -63,8 +64,8 @@ export function set<Type>(
version: string, version: string,
store = getDefaultStore() store = getDefaultStore()
): Promise<void> { ): Promise<void> {
return store.withIDBStore("readwrite", (store) => { return store.withIDBStore("readwrite", (idbstore) => {
store.put({ version, value }, key); idbstore.put({ version, value }, key);
}); });
} }
@ -72,14 +73,14 @@ export function del(
key: IDBValidKey, key: IDBValidKey,
store = getDefaultStore() store = getDefaultStore()
): Promise<void> { ): Promise<void> {
return store.withIDBStore("readwrite", (store) => { return store.withIDBStore("readwrite", (idbstore) => {
store.delete(key); idbstore.delete(key);
}); });
} }
export function clear(store = getDefaultStore()): Promise<void> { export function clear(store = getDefaultStore()): Promise<void> {
return store.withIDBStore("readwrite", (store) => { return store.withIDBStore("readwrite", (idbstore) => {
store.clear(); idbstore.clear();
}); });
} }
@ -87,16 +88,15 @@ export function keys(store = getDefaultStore()): Promise<IDBValidKey[]> {
const dbkeys: IDBValidKey[] = []; const dbkeys: IDBValidKey[] = [];
return store return store
.withIDBStore("readonly", (store) => { .withIDBStore("readonly", (idbstore) => {
// This would be store.getAllKeys(), but it isn't supported by Edge or Safari. // This would be store.getAllKeys(), but it isn't supported by Edge or Safari.
// And openKeyCursor isn't supported by Safari. // And openKeyCursor isn't supported by Safari.
(store.openKeyCursor || store.openCursor).call( (idbstore.openKeyCursor || idbstore.openCursor).call(idbstore).onsuccess =
store function () {
).onsuccess = function () { if (!this.result) return;
if (!this.result) return; dbkeys.push(this.result.key);
dbkeys.push(this.result.key); this.result.continue();
this.result.continue(); };
};
}) })
.then(() => dbkeys); .then(() => dbkeys);
} }

View File

@ -30,8 +30,8 @@ export function searchBox(): HTMLElement {
const jumpTo = (entry: SearchEntry) => { const jumpTo = (entry: SearchEntry) => {
// If page is different jump to that // If page is different jump to that
if (global) { if (global) {
const currentPage = document.querySelector<HTMLElement>(".page.active") const currentPage =
.dataset.tab; document.querySelector<HTMLElement>(".page.active").dataset.tab;
if (currentPage !== entry.page) { if (currentPage !== entry.page) {
TabManager.instance.setActive(entry.page); TabManager.instance.setActive(entry.page);
} }
@ -193,9 +193,8 @@ export function searchBox(): HTMLElement {
return; return;
default: default:
if (sel.value !== oldValue) { if (sel.value !== oldValue) {
const currentPage = document.querySelector<HTMLElement>( const currentPage =
".page.active" document.querySelector<HTMLElement>(".page.active");
);
search(sel.value, currentPage.dataset.tab); search(sel.value, currentPage.dataset.tab);
oldValue = sel.value; oldValue = sel.value;
} }

View File

@ -1,5 +1,7 @@
export function nextAnimationFrame(): Promise<void> { export function nextAnimationFrame(): Promise<void> {
return new Promise((resolve) => requestAnimationFrame(() => resolve())); return new Promise((resolve) => {
requestAnimationFrame(() => resolve());
});
} }
export function delay(ms: number): Promise<void> { export function delay(ms: number): Promise<void> {