Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Oct 10, 2020
1 parent 60804e9 commit ce835ed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 37 deletions.
14 changes: 7 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {isBackgroundPage} from 'webext-detect-page';
import toMilliseconds, {TimeDescriptor} from '@sindresorhus/to-milliseconds';

// @ts-ignore
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/promise-function-async
const getPromise = (executor: () => void) => <T>(key?): Promise<T> => new Promise((resolve, reject) => {
// @ts-ignore
// @ts-expect-error
executor(key, result => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
Expand All @@ -18,11 +18,11 @@ function timeInTheFuture(time: TimeDescriptor): number {
return Date.now() + toMilliseconds(time);
}

// @ts-ignore
// @ts-expect-error
const storageGet = getPromise((...args) => chrome.storage.local.get(...args));
// @ts-ignore
// @ts-expect-error
const storageSet = getPromise((...args) => chrome.storage.local.set(...args));
// @ts-ignore
// @ts-expect-error
const storageRemove = getPromise((...args) => chrome.storage.local.remove(...args));

type Primitive = boolean | number | string;
Expand Down Expand Up @@ -68,7 +68,7 @@ async function get<TValue extends Value>(key: string): Promise<TValue | undefine

async function set<TValue extends Value>(key: string, value: TValue, maxAge: TimeDescriptor = {days: 30}): Promise<TValue> {
if (typeof value === 'undefined') {
// @ts-ignore This never happens in TS because `value` can't be undefined
// @ts-expect-error This never happens in TS because `value` can't be undefined
return;
}

Expand Down Expand Up @@ -181,7 +181,7 @@ function init(): void {
chrome.alarms.onAlarm.addListener(alarm => {
if (alarm.name === 'webext-storage-cache' && lastRun < Date.now() - 1000) {
lastRun = Date.now();
deleteExpired();
void deleteExpired();
}
});
} else {
Expand Down
30 changes: 9 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,14 @@
"browser",
"webextensions"
],
"extensions": [
"ts"
],
"overrides": [
{
"files": "**/*.ts",
"extends": "xo-typescript",
"parserOptions": {
"project": "./tsconfig.xo.json"
}
}
],
"rules": {
"@typescript-eslint/return-await": 0,
"import/extensions": 0,
"import/no-unassigned-import": 0,
"import/no-useless-path-segments": 0,
"unicorn/import-index": 0
"no-promise-executor-return": 0,
"unicorn/import-index": 0,
"unicorn/no-object-as-default-parameter": 0
}
},
"ava": {
Expand All @@ -74,16 +65,13 @@
},
"devDependencies": {
"@sindresorhus/tsconfig": "^0.7.0",
"@types/chrome": "0.0.95",
"@types/chrome": "0.0.124",
"@types/sinon-chrome": "^2.2.6",
"@typescript-eslint/eslint-plugin": "^2.19.2",
"@typescript-eslint/parser": "^2.19.2",
"ava": "^3.3.0",
"eslint-config-xo-typescript": "^0.26.0",
"sinon": "^8.1.1",
"sinon": "^9.2.0",
"sinon-chrome": "^3.0.1",
"tsd": "^0.11.0",
"typescript": "^3.7.5",
"xo": "^0.26.0"
"tsd": "^0.13.1",
"typescript": "^4.0.3",
"xo": "^0.33.1"
}
}
2 changes: 0 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ test.serial('set() with undefined', async t => {
t.is(chrome.storage.local.set.callCount, 0);
});

test.todo('set() with past maxAge should throw');

test.serial('set() with value', async t => {
const maxAge = 20;
await cache.set('name', 'Anne', {days: maxAge});
Expand Down
7 changes: 0 additions & 7 deletions tsconfig.xo.json

This file was deleted.

0 comments on commit ce835ed

Please sign in to comment.