Fix lint issues
All checks were successful
continuous-integration/drone Build is passing

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-alert": "off",
"no-console": "off",
"no-shadow": "off",
"func-names": "off",
"default-param-last": "off",
"dot-notation": ["error", { allowPattern: "^[A-Z][a-z]+$" }],
"@typescript-eslint/ban-ts-comment": [
"error",
@ -27,5 +29,7 @@ module.exports = {
"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 {
readonly dbp: Promise<IDBDatabase>;
// eslint-disable-next-line default-param-last
constructor(dbName = "tg-cache", readonly storeName = "keyval") {
this.dbp = new Promise((resolve, reject) => {
const openreq = indexedDB.open(dbName, 1);
@ -51,8 +52,8 @@ export function get<Type>(
): Promise<CacheEntry<Type>> {
let req: IDBRequest;
return store
.withIDBStore("readonly", (store) => {
req = store.get(key);
.withIDBStore("readonly", (idbstore) => {
req = idbstore.get(key);
})
.then(() => req.result);
}
@ -63,8 +64,8 @@ export function set<Type>(
version: string,
store = getDefaultStore()
): Promise<void> {
return store.withIDBStore("readwrite", (store) => {
store.put({ version, value }, key);
return store.withIDBStore("readwrite", (idbstore) => {
idbstore.put({ version, value }, key);
});
}
@ -72,14 +73,14 @@ export function del(
key: IDBValidKey,
store = getDefaultStore()
): Promise<void> {
return store.withIDBStore("readwrite", (store) => {
store.delete(key);
return store.withIDBStore("readwrite", (idbstore) => {
idbstore.delete(key);
});
}
export function clear(store = getDefaultStore()): Promise<void> {
return store.withIDBStore("readwrite", (store) => {
store.clear();
return store.withIDBStore("readwrite", (idbstore) => {
idbstore.clear();
});
}
@ -87,12 +88,11 @@ export function keys(store = getDefaultStore()): Promise<IDBValidKey[]> {
const dbkeys: IDBValidKey[] = [];
return store
.withIDBStore("readonly", (store) => {
.withIDBStore("readonly", (idbstore) => {
// This would be store.getAllKeys(), but it isn't supported by Edge or Safari.
// And openKeyCursor isn't supported by Safari.
(store.openKeyCursor || store.openCursor).call(
store
).onsuccess = function () {
(idbstore.openKeyCursor || idbstore.openCursor).call(idbstore).onsuccess =
function () {
if (!this.result) return;
dbkeys.push(this.result.key);
this.result.continue();

View file

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

View file

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