Skip to content

Commit 1179a93

Browse files
DX 691 (#893)
* fix: generics and update biome * chore: fix linter issues
1 parent 9bd1ff4 commit 1179a93

20 files changed

+140
-142
lines changed

biome.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",
3-
2+
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
43
"linter": {
54
"enabled": true,
65
"rules": {
76
"recommended": true,
8-
"a11y": {
9-
"noSvgWithoutTitle": "off"
10-
},
117
"correctness": {
12-
"noUnusedVariables": "warn"
13-
},
14-
"security": {
15-
"noDangerouslySetInnerHtml": "off"
16-
},
17-
"style": {
18-
"useBlockStatements": "error",
19-
"noNonNullAssertion": "off"
8+
"noUnusedVariables": "error"
209
},
2110
"performance": {
2211
"noDelete": "off"
2312
},
24-
"suspicious":{
13+
"nursery": {
14+
"useAwait": "error"
15+
},
16+
"complexity": {
17+
"noBannedTypes": "off"
18+
},
19+
"suspicious": {
2520
"noExplicitAny": "off"
21+
},
22+
"style": {
23+
"noNonNullAssertion": "off"
2624
}
2725
},
28-
"ignore": ["node_modules", ".next", "dist", ".nuxt", ".contentlayer"]
26+
"ignore": ["node_modules", "dist"]
2927
},
3028
"formatter": {
3129
"indentStyle": "space",
3230
"indentWidth": 2,
3331
"enabled": true,
34-
"lineWidth": 100,
35-
"ignore": ["node_modules", ".next", "dist", ".nuxt", ".contentlayer"]
32+
"lineWidth": 100
33+
},
34+
"organizeImports": {
35+
"enabled": true
3636
}
3737
}

bun.lockb

806 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"@types/crypto-js": "^4.1.3",
7373
"bun-types": "^1.0.6",
7474
"tsup": "^7.2.0",
75-
"@biomejs/biome": "^1.3.0",
75+
"@biomejs/biome": "latest",
7676
"husky": "^8.0.3"
7777
},
7878
"dependencies": {

pkg/commands/geo_dist.test.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { expect, test } from "bun:test";
22
import { newHttpClient } from "../test-utils";
33

4-
5-
64
import { GeoAddCommand } from "./geo_add";
75
import { GeoDistCommand } from "./geo_dist";
86

@@ -15,11 +13,9 @@ test("should return distance successfully in meters", async () => {
1513
{ longitude: 15.087269, latitude: 37.502669, member: "Catania" },
1614
]).exec(client);
1715

18-
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania"]).exec(
19-
client,
20-
);
16+
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania"]).exec(client);
2117

22-
expect(res).toEqual( 166274.1516);
18+
expect(res).toEqual(166274.1516);
2319
});
2420

2521
test("should return distance for object members", async () => {
@@ -29,13 +25,15 @@ test("should return distance for object members", async () => {
2925
{ longitude: 15.087269, latitude: 37.502669, member: { name: "Catania" } },
3026
]).exec(client);
3127

32-
const res = await new GeoDistCommand(["Sicily", { name: "Palermo" }, {
33-
name: "Catania",
34-
}]).exec(
35-
client,
36-
);
28+
const res = await new GeoDistCommand([
29+
"Sicily",
30+
{ name: "Palermo" },
31+
{
32+
name: "Catania",
33+
},
34+
]).exec(client);
3735

38-
expect(res).toEqual( 166274.1516);
36+
expect(res).toEqual(166274.1516);
3937
});
4038

4139
test("should return distance successfully in kilometers", async () => {
@@ -45,10 +43,9 @@ test("should return distance successfully in kilometers", async () => {
4543
{ longitude: 15.087269, latitude: 37.502669, member: "Catania" },
4644
]).exec(client);
4745

48-
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "KM"])
49-
.exec(client);
46+
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "KM"]).exec(client);
5047

51-
expect(res).toEqual( 166.2742);
48+
expect(res).toEqual(166.2742);
5249
});
5350

5451
test("should return distance successfully in miles", async () => {
@@ -58,10 +55,9 @@ test("should return distance successfully in miles", async () => {
5855
{ longitude: 15.087269, latitude: 37.502669, member: "Catania" },
5956
]).exec(client);
6057

61-
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "MI"])
62-
.exec(client);
58+
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "MI"]).exec(client);
6359

64-
expect(res).toEqual( 103.3182);
60+
expect(res).toEqual(103.3182);
6561
});
6662

6763
test("should return distance successfully in feet", async () => {
@@ -71,14 +67,13 @@ test("should return distance successfully in feet", async () => {
7167
{ longitude: 15.087269, latitude: 37.502669, member: "Catania" },
7268
]).exec(client);
7369

74-
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "FT"])
75-
.exec(client);
70+
const res = await new GeoDistCommand(["Sicily", "Palermo", "Catania", "FT"]).exec(client);
7671

77-
expect(res?.toString()).toEqual( "545518.8700");
72+
expect(res?.toString()).toEqual("545518.8700");
7873
});
7974

8075
test("should return null if members doesn't exist", async () => {
8176
const res = await new GeoDistCommand(["Sicily", "FOO", "BAR"]).exec(client);
8277

83-
expect(res).toEqual( null);
78+
expect(res).toEqual(null);
8479
});

pkg/commands/geo_dist.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { Command, CommandOptions } from "./command";
33
/**
44
* @see https://redis.io/commands/geodist
55
*/
6-
export class GeoDistCommand<TMemberType = string>
7-
extends Command<number | null, number | null> {
6+
export class GeoDistCommand<TMemberType = string> extends Command<number | null, number | null> {
87
constructor(
98
[key, member1, member2, unit = "M"]: [
109
key: string,

pkg/commands/geo_search.ts

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ type OptionMappings = {
3333
};
3434

3535
type GeoSearchOptions<TOptions> = {
36-
[K in
37-
keyof TOptions as K extends keyof OptionMappings
38-
? OptionMappings[K]
39-
: never]: K extends "withHash"
36+
[K in keyof TOptions as K extends keyof OptionMappings
37+
? OptionMappings[K]
38+
: never]: K extends "withHash"
4039
? string
4140
: K extends "withCoord"
42-
? { long: number; lat: number }
43-
: K extends "withDist"
44-
? number
45-
: never;
41+
? { long: number; lat: number }
42+
: K extends "withDist"
43+
? number
44+
: never;
4645
};
4746

4847
type GeoSearchResponse<TOptions, TMemberType> = ({
@@ -96,32 +95,31 @@ export class GeoSearchCommand<
9695
return { member };
9796
}
9897
});
99-
} else {
100-
return result.map((members) => {
101-
let counter = 1;
102-
const obj = {} as any;
98+
}
99+
return result.map((members) => {
100+
let counter = 1;
101+
const obj = {} as any;
103102

104-
try {
105-
obj.member = JSON.parse(members[0] as string);
106-
} catch {
107-
obj.member = members[0];
108-
}
103+
try {
104+
obj.member = JSON.parse(members[0] as string);
105+
} catch {
106+
obj.member = members[0];
107+
}
109108

110-
if (opts.withDist) {
111-
obj.dist = parseFloat(members[counter++]);
112-
}
113-
if (opts.withHash) {
114-
obj.hash = members[counter++].toString();
115-
}
116-
if (opts.withCoord) {
117-
obj.coord = {
118-
long: parseFloat(members[counter][0]),
119-
lat: parseFloat(members[counter][1]),
120-
};
121-
}
122-
return obj;
123-
});
124-
}
109+
if (opts.withDist) {
110+
obj.dist = parseFloat(members[counter++]);
111+
}
112+
if (opts.withHash) {
113+
obj.hash = members[counter++].toString();
114+
}
115+
if (opts.withCoord) {
116+
obj.coord = {
117+
long: parseFloat(members[counter][0]),
118+
lat: parseFloat(members[counter][1]),
119+
};
120+
}
121+
return obj;
122+
});
125123
};
126124

127125
super(

pkg/commands/hgetall.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function deserialize<TData extends Record<string, unknown>>(result: string[]): T
2727
/**
2828
* @see https://redis.io/commands/hgetall
2929
*/
30-
export class HGetAllCommand<TData extends Record<string, unknown>,> extends Command<
30+
export class HGetAllCommand<TData extends Record<string, unknown>> extends Command<
3131
unknown | null,
3232
TData | null
3333
> {

pkg/commands/hmget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function deserialize<TData extends Record<string, unknown>>(
2929
*
3030
* @see https://redis.io/commands/hmget
3131
*/
32-
export class HMGetCommand<TData extends Record<string, unknown>,> extends Command<
32+
export class HMGetCommand<TData extends Record<string, unknown>> extends Command<
3333
(string | null)[],
3434
TData | null
3535
> {

pkg/commands/xgroup.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("XGROUP CREATE", () => {
2626
]).exec(client);
2727
expect(res).toEqual("OK");
2828
});
29-
test("should return error if stream and mkstream don't exist ", async () => {
29+
test("should return error if stream and mkstream don't exist ", () => {
3030
const throwable = async () => {
3131
const key = newKey();
3232
const group = newKey();
@@ -120,7 +120,7 @@ describe("XGROUP DESTROY", () => {
120120
expect(res).toEqual(1);
121121
});
122122

123-
test("should throw if stream doesn't exist", async () => {
123+
test("should throw if stream doesn't exist", () => {
124124
const throwable = async () => {
125125
const key = newKey();
126126
const group = newKey();

pkg/commands/xgroup.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ type XGroupCommandType =
3131
type XGroupReturnType<T extends XGroupCommandType> = T["type"] extends "CREATE"
3232
? string
3333
: T["type"] extends "CREATECONSUMER"
34-
? 0 | 1
35-
: T["type"] extends "DELCONSUMER"
36-
? number
37-
: T["type"] extends "DESTROY"
38-
? 0 | 1
39-
: T["type"] extends "SETID"
40-
? string
41-
: never;
34+
? 0 | 1
35+
: T["type"] extends "DELCONSUMER"
36+
? number
37+
: T["type"] extends "DESTROY"
38+
? 0 | 1
39+
: T["type"] extends "SETID"
40+
? string
41+
: never;
4242

4343
/**
4444
* @see https://redis.io/commands/xgroup

0 commit comments

Comments
 (0)