diff --git a/package.json b/package.json index 0739ed8..7675ef8 100644 --- a/package.json +++ b/package.json @@ -52,18 +52,18 @@ ], "devDependencies": { "@sindresorhus/tsconfig": "^3.0.1", - "@types/jsdom": "^20.0.0", - "@types/node": "^18.11.0", + "@types/jsdom": "^21.1.1", + "@types/node": "^20.2.5", "@types/zen-observable": "^0.8.3", - "ava": "^4.3.3", + "ava": "^5.3.0", "del-cli": "^5.0.0", "jsdom": "^20.0.1", - "rxjs": "^7.5.7", + "rxjs": "^7.8.1", "tempy": "^3.0.0", "ts-node": "^10.9.1", - "typescript": "~4.8.4", - "xo": "^0.52.4", - "zen-observable": "^0.8.15" + "typescript": "^5.0.4", + "xo": "^0.54.2", + "zen-observable": "^0.10.0" }, "sideEffects": false, "ava": { diff --git a/source/index.ts b/source/index.ts index 65b579b..07528b2 100644 --- a/source/index.ts +++ b/source/index.ts @@ -105,20 +105,34 @@ function is(value: unknown): TypeName { } switch (typeof value) { - case 'undefined': + case 'undefined': { return 'undefined'; - case 'string': + } + + case 'string': { return 'string'; - case 'number': + } + + case 'number': { return Number.isNaN(value) ? 'NaN' : 'number'; - case 'boolean': + } + + case 'boolean': { return 'boolean'; - case 'function': + } + + case 'function': { return 'Function'; - case 'bigint': + } + + case 'bigint': { return 'bigint'; - case 'symbol': + } + + case 'symbol': { return 'symbol'; + } + default: } @@ -179,6 +193,7 @@ is.array = (value: unknown, assertion?: (value: T) => value is T): return true; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return value.every(element => assertion(element)); }; @@ -251,6 +266,7 @@ is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer'); is.dataView = isObjectOfType('DataView'); +// eslint-disable-next-line @typescript-eslint/no-unsafe-argument is.enumCase = (value: unknown, targetEnum: T): boolean => Object.values(targetEnum as any).includes(value as string); is.directInstanceOf = (instance: unknown, class_: Class): instance is T => Object.getPrototypeOf(instance) === class_.prototype; diff --git a/test/test.ts b/test/test.ts index 5f57ab9..d686439 100644 --- a/test/test.ts +++ b/test/test.ts @@ -603,7 +603,7 @@ const testType = (t: ExecutionContext, type: string, exclude?: string[]) => { for (const fixture of fixtures) { assertIs(testIs(fixture), `Value: ${inspect(fixture)}`); - const valueType = typeDescription ? typeDescription : typename; + const valueType = typeDescription ?? typename; if (isTypeUnderTest) { t.notThrows(() => { @@ -1611,6 +1611,7 @@ test('is.any', t => { t.false(is.any([is.boolean, is.number], 'unicorns', [], new Map())); t.throws(() => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument is.any(null as any, true); }); @@ -1635,6 +1636,7 @@ test('is.any', t => { }); t.throws(() => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument assert.any(null as any, true); }); @@ -1673,6 +1675,7 @@ test('is.all', t => { t.true(is.all(is.array, ['1'], ['2'])); t.throws(() => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument is.all(null as any, true); }); @@ -1697,6 +1700,7 @@ test('is.all', t => { }); t.throws(() => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument assert.all(null as any, true); });