From ffe1534c66226aef66abad01a282a5a963acb5d2 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Thu, 25 May 2023 20:36:50 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=B7=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache-item.ts | 4 ++-- index.ts | 3 +++ package.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cache-item.ts b/cache-item.ts index 2c345cb..55d89c6 100644 --- a/cache-item.ts +++ b/cache-item.ts @@ -22,11 +22,11 @@ export default class CacheItem< Updater extends ((...args: unknown[]) => Promise) = ((...args: unknown[]) => Promise), Arguments extends unknown[] = Parameters, > { + readonly maxAge: TimeDescriptor; + readonly staleWhileRevalidate: TimeDescriptor; #cacheKey: CacheKey; #updater: Updater | undefined; #shouldRevalidate: ((cachedValue: ScopedValue) => boolean) | undefined; - readonly maxAge: TimeDescriptor; - readonly staleWhileRevalidate: TimeDescriptor; constructor( public name: string, diff --git a/index.ts b/index.ts index 2bd2578..771b3cc 100644 --- a/index.ts +++ b/index.ts @@ -80,6 +80,7 @@ async function set( throw new TypeError('Expected a value as the second argument'); } + // eslint-disable-next-line unicorn/no-typeof-undefined -- TODO if (typeof value === 'undefined') { await delete_(key); } else { @@ -106,6 +107,7 @@ async function deleteWithLogic( const wholeCache = (await chromeP.storage.local.get()) as Record; const removableItems: string[] = []; for (const [key, value] of Object.entries(wholeCache)) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (key.startsWith('cache:') && (logic?.(value) ?? true)) { removableItems.push(key); } @@ -177,6 +179,7 @@ function function_< return cachedItem.data; }; + // eslint-disable-next-line @typescript-eslint/promise-function-async -- TODO function memoizePending(...args: Arguments) { const userKey = getUserKey(name, cacheKey, args); if (inFlightCache.has(userKey)) { diff --git a/package.json b/package.json index 0d09aef..93628fe 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,6 @@ "sinon-chrome": "^3.0.1", "tsd": "^0.25.0", "typescript": "^4.9.5", - "xo": "^0.53.1" + "xo": "^0.54.2" } }