From f360c36cfa2899f469189cbea9c401c9f5278927 Mon Sep 17 00:00:00 2001 From: ogzhanolguncu Date: Fri, 16 Feb 2024 11:33:15 +0300 Subject: [PATCH 1/2] fix: generics and update biome --- biome.json | 31 +++++++++---------- bun.lockb | Bin 60106 -> 60912 bytes package.json | 2 +- pkg/commands/geo_search.ts | 62 ++++++++++++++++++------------------- pkg/pipeline.ts | 24 +++++++------- pkg/redis.test.ts | 33 +++++++++++--------- pkg/redis.ts | 24 +++++++------- pkg/script.test.ts | 18 ++++++----- tsconfig.json | 1 - 9 files changed, 98 insertions(+), 97 deletions(-) diff --git a/biome.json b/biome.json index 1fe0b1c5..d64e4e8c 100644 --- a/biome.json +++ b/biome.json @@ -1,37 +1,34 @@ { - "$schema": "https://biomejs.dev/schemas/1.0.0/schema.json", - + "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", "linter": { "enabled": true, "rules": { "recommended": true, - "a11y": { - "noSvgWithoutTitle": "off" - }, "correctness": { - "noUnusedVariables": "warn" - }, - "security": { - "noDangerouslySetInnerHtml": "off" - }, - "style": { - "useBlockStatements": "error", - "noNonNullAssertion": "off" + "noUnusedVariables": "error" }, "performance": { "noDelete": "off" }, - "suspicious":{ + "nursery": { + "useAwait": "error" + }, + "complexity": { + "noBannedTypes": "off" + }, + "suspicious": { "noExplicitAny": "off" } }, - "ignore": ["node_modules", ".next", "dist", ".nuxt", ".contentlayer"] + "ignore": ["node_modules", "dist"] }, "formatter": { "indentStyle": "space", "indentWidth": 2, "enabled": true, - "lineWidth": 100, - "ignore": ["node_modules", ".next", "dist", ".nuxt", ".contentlayer"] + "lineWidth": 100 + }, + "organizeImports": { + "enabled": true } } diff --git a/bun.lockb b/bun.lockb index e95ff4b7bb1dc4ce5e5f246b9538001ccda3d4dc..f1a4c6ee024a89b0b34a3137d72df9298b0154b6 100755 GIT binary patch delta 2614 zcmbu>eKb^Q90%|_Gna-+tZk?bMMqLIL`hrZts%-w)_5zSOcYB#pWpX+?$0yaV{ZK|&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|`CT<~Ml$F0;EUFZycyU$`-ypi`UvFnZ(2oRx`k$uCO+m4hs2|KR>(Q72z7YrDX{ ztetLsa;X1y@XXxGZhej}Z9?Y+ePVj2X2bhX%az4vuBj!vcK0#Th7Sz;))Iu`!`Aed z`kW+Na9HL(VXs-2QTkBBJ~^hM{Z_lx>4Z2ru+x0NLvk!hAb5Mk`}D-g1yzX$uQ6NZ zBq*xh%xpO~zA=CA@PW&z9hDz;rM@Tr;A~aiW8I^H&ivXdF_BgDQ&#KYyo%3z$8NW$ zDq>|8PnCDPs(FVdYm+0iElVcV-zekDW*y-9yU`7g|7r9dJ~3=uH+tjNl^)ysdIWRT zjBmZlqGMx$!nM;LoRfvwq*UczsB7M5{6M zO#j)|Oln_(Y-9zKJULzCU%c5(quW-_VLcf>y=NWSSRX_E<~ZIDz2Mn!kNQI-L~ud9 zMy_LqPu8X)jSZiY_v&5ANL84oNR{j~Mm4nbQlrM$@W_cgtM+3(Zyag`t>ka&Ij*#9 zK3BlyX*`eL^>U^LvR~&rhkBu6hmU3`X+t63>g`dt!|{bZ|dmF T+0Xo4siSc>uP!A6iVyt@9LLRj diff --git a/package.json b/package.json index cf07e509..aa73c131 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "@types/crypto-js": "^4.1.3", "bun-types": "^1.0.6", "tsup": "^7.2.0", - "@biomejs/biome": "^1.3.0", + "@biomejs/biome": "latest", "husky": "^8.0.3" }, "dependencies": { diff --git a/pkg/commands/geo_search.ts b/pkg/commands/geo_search.ts index ae237b24..73f36273 100644 --- a/pkg/commands/geo_search.ts +++ b/pkg/commands/geo_search.ts @@ -33,16 +33,15 @@ type OptionMappings = { }; type GeoSearchOptions = { - [K in - keyof TOptions as K extends keyof OptionMappings - ? OptionMappings[K] - : never]: K extends "withHash" + [K in keyof TOptions as K extends keyof OptionMappings + ? OptionMappings[K] + : never]: K extends "withHash" ? string : K extends "withCoord" - ? { long: number; lat: number } - : K extends "withDist" - ? number - : never; + ? { long: number; lat: number } + : K extends "withDist" + ? number + : never; }; type GeoSearchResponse = ({ @@ -96,32 +95,31 @@ export class GeoSearchCommand< return { member }; } }); - } else { - return result.map((members) => { - let counter = 1; - const obj = {} as any; + } + return result.map((members) => { + let counter = 1; + const obj = {} as any; - try { - obj.member = JSON.parse(members[0] as string); - } catch { - obj.member = members[0]; - } + try { + obj.member = JSON.parse(members[0] as string); + } catch { + obj.member = members[0]; + } - if (opts.withDist) { - obj.dist = parseFloat(members[counter++]); - } - if (opts.withHash) { - obj.hash = members[counter++].toString(); - } - if (opts.withCoord) { - obj.coord = { - long: parseFloat(members[counter][0]), - lat: parseFloat(members[counter][1]), - }; - } - return obj; - }); - } + if (opts.withDist) { + obj.dist = parseFloat(members[counter++]); + } + if (opts.withHash) { + obj.hash = members[counter++].toString(); + } + if (opts.withCoord) { + obj.coord = { + long: parseFloat(members[counter][0]), + lat: parseFloat(members[counter][1]), + }; + } + return obj; + }); }; super( diff --git a/pkg/pipeline.ts b/pkg/pipeline.ts index dfdb48a7..847e94d0 100644 --- a/pkg/pipeline.ts +++ b/pkg/pipeline.ts @@ -415,38 +415,38 @@ export class Pipeline[] = []> { /** * @see https://redis.io/commands/geoadd */ - geoadd = (...args: CommandArgs) => - this.chain(new GeoAddCommand(args, this.commandOptions)); + geoadd = (...args: CommandArgs>) => + this.chain(new GeoAddCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geodist */ - geodist = (...args: CommandArgs) => - this.chain(new GeoDistCommand(args, this.commandOptions)); + geodist = (...args: CommandArgs>) => + this.chain(new GeoDistCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geopos */ - geopos = (...args: CommandArgs) => - this.chain(new GeoPosCommand(args, this.commandOptions)); + geopos = (...args: CommandArgs>) => + this.chain(new GeoPosCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geohash */ - geohash = (...args: CommandArgs) => - this.chain(new GeoHashCommand(args, this.commandOptions)); + geohash = (...args: CommandArgs>) => + this.chain(new GeoHashCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geosearch */ - geosearch = (...args: CommandArgs) => - this.chain(new GeoSearchCommand(args, this.commandOptions)); + geosearch = (...args: CommandArgs>) => + this.chain(new GeoSearchCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geosearchstore */ - geosearchstore = (...args: CommandArgs) => - this.chain(new GeoSearchStoreCommand(args, this.commandOptions)); + geosearchstore = (...args: CommandArgs>) => + this.chain(new GeoSearchStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/get diff --git a/pkg/redis.test.ts b/pkg/redis.test.ts index ef151fd9..f7bd9a0c 100644 --- a/pkg/redis.test.ts +++ b/pkg/redis.test.ts @@ -9,14 +9,18 @@ const { newKey, cleanup } = keygen(); afterEach(cleanup); describe("when storing base64 data", () => { - test("general", async () => { - const redis = new Redis(client); - const key = newKey(); - const value = "VXBzdGFzaCBpcyByZWFsbHkgY29vbA"; - await redis.set(key, value); - const res = await redis.get(key); - expect(res).toEqual(value); - }); + test( + "general", + async () => { + const redis = new Redis(client); + const key = newKey(); + const value = "VXBzdGFzaCBpcyByZWFsbHkgY29vbA"; + await redis.set(key, value); + const res = await redis.get(key); + expect(res).toEqual(value); + }, + { timeout: 150000 }, + ); // decode("OK") => 8 test("getting '8'", async () => { @@ -37,7 +41,7 @@ describe("when storing base64 data", () => { }); }); -describe("mget", async () => { +describe("mget", () => { const key = newKey(); const key1 = newKey(); const value = "foobar"; @@ -132,7 +136,7 @@ test("special data", () => { await redis.set(key, value); const res = await redis.get(key); - expect(res!).toEqual(value); + expect(res).toEqual(value); }); test("empty string", async () => { const key = newKey(); @@ -141,14 +145,14 @@ test("special data", () => { await redis.set(key, value); const res = await redis.get(key); - expect(res!).toEqual(value); + expect(res).toEqual(value); }); test("not found key", async () => { const redis = new Redis(client); const res = await redis.get(newKey()); - expect(res!).toEqual(null); + expect(res).toEqual(null); }); test("with encodeURIComponent", async () => { @@ -157,8 +161,7 @@ test("special data", () => { const redis = new Redis(client); await redis.set(key, encodeURIComponent(value)); const res = await redis.get(key); - - expect(decodeURIComponent(res!)).toEqual(value); + if (res) expect(decodeURIComponent(res)).toEqual(value); }); test("without encodeURIComponent", async () => { @@ -168,7 +171,7 @@ test("special data", () => { await redis.set(key, value); const res = await redis.get(key); - expect(res!).toEqual(value); + expect(res).toEqual(value); }); test("emojis", async () => { const key = newKey(); diff --git a/pkg/redis.ts b/pkg/redis.ts index 70125ee7..e38768c5 100644 --- a/pkg/redis.ts +++ b/pkg/redis.ts @@ -515,38 +515,38 @@ export class Redis { /** * @see https://redis.io/commands/geoadd */ - geoadd = (...args: CommandArgs) => - new GeoAddCommand(args, this.opts).exec(this.client); + geoadd = (...args: CommandArgs>) => + new GeoAddCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geopos */ - geopos = (...args: CommandArgs) => - new GeoPosCommand(args, this.opts).exec(this.client); + geopos = (...args: CommandArgs>) => + new GeoPosCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geodist */ - geodist = (...args: CommandArgs) => - new GeoDistCommand(args, this.opts).exec(this.client); + geodist = (...args: CommandArgs>) => + new GeoDistCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geohash */ - geohash = (...args: CommandArgs) => - new GeoHashCommand(args, this.opts).exec(this.client); + geohash = (...args: CommandArgs>) => + new GeoHashCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geosearch */ - geosearch = (...args: CommandArgs) => - new GeoSearchCommand(args, this.opts).exec(this.client); + geosearch = (...args: CommandArgs>) => + new GeoSearchCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geosearchstore */ - geosearchstore = (...args: CommandArgs) => - new GeoSearchStoreCommand(args, this.opts).exec(this.client); + geosearchstore = (...args: CommandArgs>) => + new GeoSearchStoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/get diff --git a/pkg/script.test.ts b/pkg/script.test.ts index 608cd711..112e2c1d 100644 --- a/pkg/script.test.ts +++ b/pkg/script.test.ts @@ -7,13 +7,17 @@ const { cleanup } = keygen(); afterEach(cleanup); describe("create a new script", () => { - test("creates a new script", async () => { - const redis = new Redis(client); - const script = redis.createScript("return ARGV[1];"); - - const res = await script.eval([], ["Hello World"]); - expect(res).toEqual("Hello World"); - }); + test( + "creates a new script", + async () => { + const redis = new Redis(client); + const script = redis.createScript("return ARGV[1];"); + + const res = await script.eval([], ["Hello World"]); + expect(res).toEqual("Hello World"); + }, + { timeout: 15000 }, + ); }); describe("sha1", () => { diff --git a/tsconfig.json b/tsconfig.json index 33c44aa8..e1e794fe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "lib": ["ESNext"], "module": "esnext", "target": "esnext", From 6ace036c29f8e00025e934358e32ffd4053eabfd Mon Sep 17 00:00:00 2001 From: ogzhanolguncu Date: Fri, 16 Feb 2024 11:36:13 +0300 Subject: [PATCH 2/2] chore: fix linter issues --- biome.json | 3 +++ pkg/commands/geo_dist.test.ts | 39 ++++++++++++++------------------- pkg/commands/geo_dist.ts | 3 +-- pkg/commands/hgetall.ts | 2 +- pkg/commands/hmget.ts | 2 +- pkg/commands/xgroup.test.ts | 4 ++-- pkg/commands/xgroup.ts | 16 +++++++------- pkg/commands/xrange.ts | 2 +- pkg/commands/xread.test.ts | 2 +- pkg/commands/xread.ts | 6 ++--- pkg/commands/xreadgroup.test.ts | 2 +- pkg/commands/xreadgroup.ts | 6 ++--- 12 files changed, 42 insertions(+), 45 deletions(-) diff --git a/biome.json b/biome.json index d64e4e8c..7076dc12 100644 --- a/biome.json +++ b/biome.json @@ -18,6 +18,9 @@ }, "suspicious": { "noExplicitAny": "off" + }, + "style": { + "noNonNullAssertion": "off" } }, "ignore": ["node_modules", "dist"] diff --git a/pkg/commands/geo_dist.test.ts b/pkg/commands/geo_dist.test.ts index e5475fd3..6de352ab 100644 --- a/pkg/commands/geo_dist.test.ts +++ b/pkg/commands/geo_dist.test.ts @@ -1,8 +1,6 @@ import { expect, test } from "bun:test"; import { newHttpClient } from "../test-utils"; - - import { GeoAddCommand } from "./geo_add"; import { GeoDistCommand } from "./geo_dist"; @@ -15,11 +13,9 @@ test("should return distance successfully in meters", async () => { { longitude: 15.087269, latitude: 37.502669, member: "Catania" }, ]).exec(client); - const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania"]).exec( - client, - ); + const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania"]).exec(client); - expect(res).toEqual( 166274.1516); + expect(res).toEqual(166274.1516); }); test("should return distance for object members", async () => { @@ -29,13 +25,15 @@ test("should return distance for object members", async () => { { longitude: 15.087269, latitude: 37.502669, member: { name: "Catania" } }, ]).exec(client); - const res = await new GeoDistCommand(["Sicily", { name: "Palermo" }, { - name: "Catania", - }]).exec( - client, - ); + const res = await new GeoDistCommand([ + "Sicily", + { name: "Palermo" }, + { + name: "Catania", + }, + ]).exec(client); - expect(res).toEqual( 166274.1516); + expect(res).toEqual(166274.1516); }); test("should return distance successfully in kilometers", async () => { @@ -45,10 +43,9 @@ test("should return distance successfully in kilometers", async () => { { longitude: 15.087269, latitude: 37.502669, member: "Catania" }, ]).exec(client); - const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "KM"]) - .exec(client); + const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "KM"]).exec(client); - expect(res).toEqual( 166.2742); + expect(res).toEqual(166.2742); }); test("should return distance successfully in miles", async () => { @@ -58,10 +55,9 @@ test("should return distance successfully in miles", async () => { { longitude: 15.087269, latitude: 37.502669, member: "Catania" }, ]).exec(client); - const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "MI"]) - .exec(client); + const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "MI"]).exec(client); - expect(res).toEqual( 103.3182); + expect(res).toEqual(103.3182); }); test("should return distance successfully in feet", async () => { @@ -71,14 +67,13 @@ test("should return distance successfully in feet", async () => { { longitude: 15.087269, latitude: 37.502669, member: "Catania" }, ]).exec(client); - const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "FT"]) - .exec(client); + const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "FT"]).exec(client); - expect(res?.toString()).toEqual( "545518.8700"); + expect(res?.toString()).toEqual("545518.8700"); }); test("should return null if members doesn't exist", async () => { const res = await new GeoDistCommand(["Sicily", "FOO", "BAR"]).exec(client); - expect(res).toEqual( null); + expect(res).toEqual(null); }); diff --git a/pkg/commands/geo_dist.ts b/pkg/commands/geo_dist.ts index df7fd4a3..ae26f825 100644 --- a/pkg/commands/geo_dist.ts +++ b/pkg/commands/geo_dist.ts @@ -3,8 +3,7 @@ import { Command, CommandOptions } from "./command"; /** * @see https://redis.io/commands/geodist */ -export class GeoDistCommand - extends Command { +export class GeoDistCommand extends Command { constructor( [key, member1, member2, unit = "M"]: [ key: string, diff --git a/pkg/commands/hgetall.ts b/pkg/commands/hgetall.ts index c51cd228..d0884f37 100644 --- a/pkg/commands/hgetall.ts +++ b/pkg/commands/hgetall.ts @@ -27,7 +27,7 @@ function deserialize>(result: string[]): T /** * @see https://redis.io/commands/hgetall */ -export class HGetAllCommand,> extends Command< +export class HGetAllCommand> extends Command< unknown | null, TData | null > { diff --git a/pkg/commands/hmget.ts b/pkg/commands/hmget.ts index ee8fd8ea..75f0e283 100644 --- a/pkg/commands/hmget.ts +++ b/pkg/commands/hmget.ts @@ -29,7 +29,7 @@ function deserialize>( * * @see https://redis.io/commands/hmget */ -export class HMGetCommand,> extends Command< +export class HMGetCommand> extends Command< (string | null)[], TData | null > { diff --git a/pkg/commands/xgroup.test.ts b/pkg/commands/xgroup.test.ts index 1b58169d..92caeb9b 100644 --- a/pkg/commands/xgroup.test.ts +++ b/pkg/commands/xgroup.test.ts @@ -26,7 +26,7 @@ describe("XGROUP CREATE", () => { ]).exec(client); expect(res).toEqual("OK"); }); - test("should return error if stream and mkstream don't exist ", async () => { + test("should return error if stream and mkstream don't exist ", () => { const throwable = async () => { const key = newKey(); const group = newKey(); @@ -120,7 +120,7 @@ describe("XGROUP DESTROY", () => { expect(res).toEqual(1); }); - test("should throw if stream doesn't exist", async () => { + test("should throw if stream doesn't exist", () => { const throwable = async () => { const key = newKey(); const group = newKey(); diff --git a/pkg/commands/xgroup.ts b/pkg/commands/xgroup.ts index d6ac4e30..7b9cbc88 100644 --- a/pkg/commands/xgroup.ts +++ b/pkg/commands/xgroup.ts @@ -31,14 +31,14 @@ type XGroupCommandType = type XGroupReturnType = T["type"] extends "CREATE" ? string : T["type"] extends "CREATECONSUMER" - ? 0 | 1 - : T["type"] extends "DELCONSUMER" - ? number - : T["type"] extends "DESTROY" - ? 0 | 1 - : T["type"] extends "SETID" - ? string - : never; + ? 0 | 1 + : T["type"] extends "DELCONSUMER" + ? number + : T["type"] extends "DESTROY" + ? 0 | 1 + : T["type"] extends "SETID" + ? string + : never; /** * @see https://redis.io/commands/xgroup diff --git a/pkg/commands/xrange.ts b/pkg/commands/xrange.ts index 4d76a0b9..81228e11 100644 --- a/pkg/commands/xrange.ts +++ b/pkg/commands/xrange.ts @@ -27,7 +27,7 @@ function deserialize>>( return obj as TData; } -export class XRangeCommand>,> extends Command< +export class XRangeCommand>> extends Command< string[][], TData > { diff --git a/pkg/commands/xread.test.ts b/pkg/commands/xread.test.ts index f34f9542..1066bb03 100644 --- a/pkg/commands/xread.test.ts +++ b/pkg/commands/xread.test.ts @@ -100,7 +100,7 @@ describe("Multiple stream", () => { test( "should throw when unbalanced is array passed", - async () => { + () => { const throwable = async () => { const streamKey1 = newKey(); await addNewItemToStream(streamKey1, client); diff --git a/pkg/commands/xread.ts b/pkg/commands/xread.ts index 6b6bbe2b..cd3c153f 100644 --- a/pkg/commands/xread.ts +++ b/pkg/commands/xread.ts @@ -16,10 +16,10 @@ type XReadOptions = XReadCommandOptions extends [infer K, infer I, ...any[]] ? [key: string, id: string, options?: { count?: number; blockMS?: number }] : never : K extends string[] - ? I extends string[] - ? [key: string[], id: string[], options?: { count?: number; blockMS?: number }] + ? I extends string[] + ? [key: string[], id: string[], options?: { count?: number; blockMS?: number }] + : never : never - : never : never; /** diff --git a/pkg/commands/xreadgroup.test.ts b/pkg/commands/xreadgroup.test.ts index 7a4dd503..acb1f949 100644 --- a/pkg/commands/xreadgroup.test.ts +++ b/pkg/commands/xreadgroup.test.ts @@ -147,7 +147,7 @@ describe("Multiple Stream", () => { expect(listOfStreams.length).toEqual(wantedAmount); }); - test("should throw when unbalanced is array passed", async () => { + test("should throw when unbalanced is array passed", () => { const throwable = async () => { const streamKey = newKey(); const group = newKey(); diff --git a/pkg/commands/xreadgroup.ts b/pkg/commands/xreadgroup.ts index 8c9361dd..06fed87a 100644 --- a/pkg/commands/xreadgroup.ts +++ b/pkg/commands/xreadgroup.ts @@ -25,10 +25,10 @@ type XReadGroupOptions = XReadGroupCommandOptions extends [ ? [group: string, consumer: string, key: string, id: string, options?: Options] : never : TKey extends string[] - ? TId extends string[] - ? [group: string, consumer: string, key: string[], id: string[], options?: Options] + ? TId extends string[] + ? [group: string, consumer: string, key: string[], id: string[], options?: Options] + : never : never - : never : never; /**