Skip to content

Commit 6cf686e

Browse files
committed
Fix linting problems and rename
1 parent 02ed613 commit 6cf686e

File tree

9 files changed

+45
-24
lines changed

9 files changed

+45
-24
lines changed

array_parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ArrayParser {
7979
consumeDimensions(): void {
8080
if (this.source[0] === "[") {
8181
while (!this.isEof()) {
82-
let char = this.nextCharacter();
82+
const char = this.nextCharacter();
8383
if (char.value === "=") break;
8484
}
8585
}

decode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ function decodeBytea(byteaStr: string): Uint8Array {
139139
}
140140

141141
function decodeByteaHex(byteaStr: string): Uint8Array {
142-
let bytesStr = byteaStr.slice(2);
143-
let bytes = new Uint8Array(bytesStr.length / 2);
142+
const bytesStr = byteaStr.slice(2);
143+
const bytes = new Uint8Array(bytesStr.length / 2);
144144
for (let i = 0, j = 0; i < bytesStr.length; i += 2, j++) {
145145
bytes[j] = parseInt(bytesStr[i] + bytesStr[i + 1], HEX);
146146
}
147147
return bytes;
148148
}
149149

150150
function decodeByteaEscape(byteaStr: string): Uint8Array {
151-
let bytes = [];
151+
const bytes = [];
152152
let i = 0;
153153
let k = 0;
154154
while (i < byteaStr.length) {

encode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function encodeDate(date: Date): string {
4141

4242
function escapeArrayElement(value: unknown): string {
4343
// deno-lint-ignore no-explicit-any
44-
let strValue = (value as any).toString();
44+
const strValue = (value as any).toString();
4545
const escapedValue = strValue.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4646

4747
return `"${escapedValue}"`;
@@ -73,7 +73,7 @@ function encodeArray(array: Array<unknown>): string {
7373
}
7474

7575
function encodeBytes(value: Uint8Array): string {
76-
let hex = Array.from(value)
76+
const hex = Array.from(value)
7777
.map((val) => (val < 10 ? `0${val.toString(16)}` : val.toString(16)))
7878
.join("");
7979
return `\\x${hex}`;

oid.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ export const Oid = {
1414
xid: 28,
1515
cid: 29,
1616
oidvector: 30,
17+
// deno-lint-ignore camelcase
1718
pg_ddl_command: 32,
19+
// deno-lint-ignore camelcase
1820
pg_type: 71,
21+
// deno-lint-ignore camelcase
1922
pg_attribute: 75,
23+
// deno-lint-ignore camelcase
2024
pg_proc: 81,
25+
// deno-lint-ignore camelcase
2126
pg_class: 83,
2227
json: 114,
2328
xml: 142,
2429
_xml: 143,
30+
// deno-lint-ignore camelcase
2531
pg_node_tree: 194,
32+
// deno-lint-ignore camelcase
2633
json_array: 199,
2734
smgr: 210,
35+
// deno-lint-ignore camelcase
2836
index_am_handler: 325,
2937
point: 600,
3038
lseg: 601,
@@ -91,6 +99,7 @@ export const Oid = {
9199
interval: 1186,
92100
_interval: 1187,
93101
_numeric: 1231,
102+
// deno-lint-ignore camelcase
94103
pg_database: 1248,
95104
_cstring: 1263,
96105
timetz: 1266,
@@ -118,21 +127,30 @@ export const Oid = {
118127
anyarray: 2277,
119128
void: 2278,
120129
trigger: 2279,
130+
// deno-lint-ignore camelcase
121131
language_handler: 2280,
122132
internal: 2281,
123133
opaque: 2282,
124134
anyelement: 2283,
125135
_record: 2287,
126136
anynonarray: 2776,
137+
// deno-lint-ignore camelcase
127138
pg_authid: 2842,
139+
// deno-lint-ignore camelcase
128140
pg_auth_members: 2843,
141+
// deno-lint-ignore camelcase
129142
_txid_snapshot: 2949,
130143
uuid: 2950,
131144
_uuid: 2951,
145+
// deno-lint-ignore camelcase
132146
txid_snapshot: 2970,
147+
// deno-lint-ignore camelcase
133148
fdw_handler: 3115,
149+
// deno-lint-ignore camelcase
134150
pg_lsn: 3220,
151+
// deno-lint-ignore camelcase
135152
_pg_lsn: 3221,
153+
// deno-lint-ignore camelcase
136154
tsm_handler: 3310,
137155
anyenum: 3500,
138156
tsvector: 3614,
@@ -146,8 +164,10 @@ export const Oid = {
146164
regdictionary: 3769,
147165
_regdictionary: 3770,
148166
jsonb: 3802,
167+
// deno-lint-ignore camelcase
149168
jsonb_array: 3807,
150169
anyrange: 3831,
170+
// deno-lint-ignore camelcase
151171
event_trigger: 3838,
152172
int4range: 3904,
153173
_int4range: 3905,
@@ -161,6 +181,7 @@ export const Oid = {
161181
_daterange: 3913,
162182
int8range: 3926,
163183
_int8range: 3927,
184+
// deno-lint-ignore camelcase
164185
pg_shseclabel: 4066,
165186
regnamespace: 4089,
166187
_regnamespace: 4090,

tests/data_types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,17 @@ testClient(async function bpcharNestedArray() {
269269
});
270270

271271
testClient(async function jsonArray() {
272-
const json_array = await CLIENT.query(
272+
const jsonArray = await CLIENT.query(
273273
`SELECT ARRAY_AGG(A) FROM (
274274
SELECT JSON_BUILD_OBJECT( 'X', '1' ) AS A
275275
UNION ALL
276276
SELECT JSON_BUILD_OBJECT( 'Y', '2' ) AS A
277277
) A`,
278278
);
279279

280-
assertEquals(json_array.rows[0][0], [{ X: "1" }, { Y: "2" }]);
280+
assertEquals(jsonArray.rows[0][0], [{ X: "1" }, { Y: "2" }]);
281281

282-
const json_array_nested = await CLIENT.query(
282+
const jsonArrayNested = await CLIENT.query(
283283
`SELECT ARRAY[ARRAY[ARRAY_AGG(A), ARRAY_AGG(A)], ARRAY[ARRAY_AGG(A), ARRAY_AGG(A)]] FROM (
284284
SELECT JSON_BUILD_OBJECT( 'X', '1' ) AS A
285285
UNION ALL
@@ -288,7 +288,7 @@ testClient(async function jsonArray() {
288288
);
289289

290290
assertEquals(
291-
json_array_nested.rows[0][0],
291+
jsonArrayNested.rows[0][0],
292292
[
293293
[
294294
[{ X: "1" }, { Y: "2" }],

tests/encode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ test("encodeObject", function () {
6363
});
6464

6565
test("encodeUint8Array", function () {
66-
const buf_1 = new Uint8Array([1, 2, 3]);
67-
const buf_2 = new Uint8Array([2, 10, 500]);
66+
const buf1 = new Uint8Array([1, 2, 3]);
67+
const buf2 = new Uint8Array([2, 10, 500]);
6868

69-
assertEquals("\\x010203", encode(buf_1));
70-
assertEquals("\\x02af4", encode(buf_2));
69+
assertEquals("\\x010203", encode(buf1));
70+
assertEquals("\\x02af4", encode(buf2));
7171
});
7272

7373
test("encodeArray", function () {

tests/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getTestClient(
44
client: Client,
55
defSetupQueries?: Array<string>,
66
) {
7-
return async function testClient(
7+
return function testClient(
88
t: Deno.TestDefinition["fn"],
99
setupQueries?: Array<string>,
1010
) {

tests/pool.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Pool } from "../pool.ts";
33
import { delay } from "../utils.ts";
44
import { DEFAULT_SETUP, TEST_CONNECTION_PARAMS } from "./constants.ts";
55

6-
async function testPool(
6+
function testPool(
77
t: (pool: Pool) => void | Promise<void>,
88
setupQueries?: Array<string> | null,
99
lazy?: boolean,
@@ -63,13 +63,13 @@ testPool(
6363
await p;
6464
assertEquals(POOL.available, 1);
6565

66-
const qs_thunks = [...Array(25)].map((_, i) =>
66+
const qsThunks = [...Array(25)].map((_, i) =>
6767
POOL.query("SELECT pg_sleep(0.1) is null, $1::text as id;", i)
6868
);
69-
const qs_promises = Promise.all(qs_thunks);
69+
const qsPromises = Promise.all(qsThunks);
7070
await delay(1);
7171
assertEquals(POOL.available, 0);
72-
const qs = await qs_promises;
72+
const qs = await qsPromises;
7373
assertEquals(POOL.available, 10);
7474
assertEquals(POOL.size, 10);
7575

@@ -101,13 +101,13 @@ testPool(async function manyQueries(POOL) {
101101
await p;
102102
assertEquals(POOL.available, 10);
103103

104-
const qs_thunks = [...Array(25)].map((_, i) =>
104+
const qsThunks = [...Array(25)].map((_, i) =>
105105
POOL.query("SELECT pg_sleep(0.1) is null, $1::text as id;", i)
106106
);
107-
const qs_promises = Promise.all(qs_thunks);
107+
const qsPromises = Promise.all(qsThunks);
108108
await delay(1);
109109
assertEquals(POOL.available, 0);
110-
const qs = await qs_promises;
110+
const qs = await qsPromises;
111111
assertEquals(POOL.available, 10);
112112
assertEquals(POOL.size, 10);
113113

utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export interface DsnResult {
7373
export function parseDsn(dsn: string): DsnResult {
7474
//URL object won't parse the URL if it doesn't recognize the protocol
7575
//This line replaces the protocol with http and then leaves it up to URL
76-
const [protocol, stripped_url] = dsn.match(/(?:(?!:\/\/).)+/g) ?? ["", ""];
77-
const url = new URL(`http:${stripped_url}`);
76+
const [protocol, strippedUrl] = dsn.match(/(?:(?!:\/\/).)+/g) ?? ["", ""];
77+
const url = new URL(`http:${strippedUrl}`);
7878

7979
return {
8080
driver: protocol,

0 commit comments

Comments
 (0)