Skip to content

Commit 16322c2

Browse files
authored
Fix eslint violations (brianc#3078)
Co-authored-by: alxndrsn <alxndrsn>
1 parent b9a528c commit 16322c2

File tree

15 files changed

+93
-50
lines changed

15 files changed

+93
-50
lines changed

Diff for: docs/theme.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export default {
3030
head: (
3131
<>
3232
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
33-
<meta name="description" content="node-postgres is a collection of node.js modules for interfacing with your PostgreSQL database." />
33+
<meta
34+
name="description"
35+
content="node-postgres is a collection of node.js modules for interfacing with your PostgreSQL database."
36+
/>
3437
<meta name="og:title" content="node-postgres" />
3538
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-100138145-1"></script>
3639
<script

Diff for: packages/pg-cursor/test/error-handling.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,24 @@ describe('error handling', function () {
3030
const queuedRead1 = cursor.read(1)
3131
const queuedRead2 = cursor.read(1)
3232

33-
assert(await immediateRead.then(() => null, (err) => err))
34-
assert(await queuedRead1.then(() => null, (err) => err))
35-
assert(await queuedRead2.then(() => null, (err) => err))
33+
assert(
34+
await immediateRead.then(
35+
() => null,
36+
(err) => err
37+
)
38+
)
39+
assert(
40+
await queuedRead1.then(
41+
() => null,
42+
(err) => err
43+
)
44+
)
45+
assert(
46+
await queuedRead2.then(
47+
() => null,
48+
(err) => err
49+
)
50+
)
3651

3752
client.end()
3853
})

Diff for: packages/pg-pool/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ function promisify(Promise, callback) {
3939
const result = new Promise(function (resolve, reject) {
4040
res = resolve
4141
rej = reject
42-
}).catch(err => {
42+
}).catch((err) => {
4343
// replace the stack trace that leads to `TCP.onStreamRead` with one that leads back to the
4444
// application that created the query
45-
Error.captureStackTrace(err);
46-
throw err;
45+
Error.captureStackTrace(err)
46+
throw err
4747
})
4848
return { callback: cb, result: result }
4949
}

Diff for: packages/pg-pool/test/idle-timeout-exit.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ if (module === require.main) {
33
const allowExitOnIdle = process.env.ALLOW_EXIT_ON_IDLE === '1'
44
const Pool = require('../index')
55

6-
const pool = new Pool({ maxLifetimeSeconds: 2, idleTimeoutMillis: 200, ...(allowExitOnIdle ? { allowExitOnIdle: true } : {}) })
6+
const pool = new Pool({
7+
maxLifetimeSeconds: 2,
8+
idleTimeoutMillis: 200,
9+
...(allowExitOnIdle ? { allowExitOnIdle: true } : {}),
10+
})
711
pool.query('SELECT NOW()', (err, res) => console.log('completed first'))
812
pool.on('remove', () => {
913
console.log('removed')

Diff for: packages/pg/bench.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const pg = require('./lib')
22

33
const params = {
4-
text:
5-
'select typname, typnamespace, typowner, typlen, typbyval, typcategory, typispreferred, typisdefined, typdelim, typrelid, typelem, typarray from pg_type where typtypmod = $1 and typisdefined = $2',
4+
text: 'select typname, typnamespace, typowner, typlen, typbyval, typcategory, typispreferred, typisdefined, typdelim, typrelid, typelem, typarray from pg_type where typtypmod = $1 and typisdefined = $2',
65
values: [-1, true],
76
}
87

Diff for: packages/pg/lib/client.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,11 @@ class Client extends EventEmitter {
520520
if (!query.callback) {
521521
result = new this._Promise((resolve, reject) => {
522522
query.callback = (err, res) => (err ? reject(err) : resolve(res))
523-
}).catch(err => {
523+
}).catch((err) => {
524524
// replace the stack trace that leads to `TCP.onStreamRead` with one that leads back to the
525525
// application that created the query
526-
Error.captureStackTrace(err);
527-
throw err;
526+
Error.captureStackTrace(err)
527+
throw err
528528
})
529529
}
530530
}

Diff for: packages/pg/lib/crypto/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ if (useLegacyCrypto) {
55
// We are on an old version of Node.js that requires legacy crypto utilities.
66
module.exports = require('./utils-legacy')
77
} else {
8-
module.exports = require('./utils-webcrypto');
8+
module.exports = require('./utils-webcrypto')
99
}

Diff for: packages/pg/lib/native/client.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ Client.prototype.query = function (config, values, callback) {
174174
result = new this._Promise((resolve, reject) => {
175175
resolveOut = resolve
176176
rejectOut = reject
177-
}).catch(err => {
178-
Error.captureStackTrace(err);
179-
throw err;
177+
}).catch((err) => {
178+
Error.captureStackTrace(err)
179+
throw err
180180
})
181181
query.callback = (err, res) => (err ? rejectOut(err) : resolveOut(res))
182182
}

Diff for: packages/pg/lib/query.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ class Query extends EventEmitter {
137137
if (this.callback) {
138138
try {
139139
this.callback(null, this._results)
140-
}
141-
catch(err) {
140+
} catch (err) {
142141
process.nextTick(() => {
143142
throw err
144143
})

Diff for: packages/pg/test/integration/client/async-stack-trace-tests.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,42 @@ process.on('unhandledRejection', function (e) {
1010
const suite = new helper.Suite()
1111

1212
// these tests will only work for if --async-stack-traces is on, which is the default starting in node 16.
13-
const NODE_MAJOR_VERSION = +process.versions.node.split('.')[0];
13+
const NODE_MAJOR_VERSION = +process.versions.node.split('.')[0]
1414
if (NODE_MAJOR_VERSION >= 16) {
1515
suite.testAsync('promise API async stack trace in pool', async function outerFunction() {
1616
async function innerFunction() {
1717
const pool = new pg.Pool()
18-
await pool.query('SELECT test from nonexistent');
18+
await pool.query('SELECT test from nonexistent')
1919
}
2020
try {
21-
await innerFunction();
22-
throw Error("should have errored");
21+
await innerFunction()
22+
throw Error('should have errored')
2323
} catch (e) {
24-
const stack = e.stack;
25-
if(!e.stack.includes("innerFunction") || !e.stack.includes("outerFunction")) {
26-
throw Error("async stack trace does not contain wanted values: " + stack);
24+
const stack = e.stack
25+
if (!e.stack.includes('innerFunction') || !e.stack.includes('outerFunction')) {
26+
throw Error('async stack trace does not contain wanted values: ' + stack)
2727
}
2828
}
2929
})
3030

3131
suite.testAsync('promise API async stack trace in client', async function outerFunction() {
3232
async function innerFunction() {
3333
const client = new pg.Client()
34-
await client.connect();
34+
await client.connect()
3535
try {
36-
await client.query('SELECT test from nonexistent');
36+
await client.query('SELECT test from nonexistent')
3737
} finally {
38-
client.end();
38+
client.end()
3939
}
4040
}
4141
try {
42-
await innerFunction();
43-
throw Error("should have errored");
42+
await innerFunction()
43+
throw Error('should have errored')
4444
} catch (e) {
45-
const stack = e.stack;
46-
if(!e.stack.includes("innerFunction") || !e.stack.includes("outerFunction")) {
47-
throw Error("async stack trace does not contain wanted values: " + stack);
45+
const stack = e.stack
46+
if (!e.stack.includes('innerFunction') || !e.stack.includes('outerFunction')) {
47+
throw Error('async stack trace does not contain wanted values: ' + stack)
4848
}
4949
}
5050
})
51-
}
51+
}

Diff for: packages/pg/test/integration/client/sasl-scram-tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ suite.testAsync('sasl/scram fails when password is empty', async () => {
7979
...config,
8080
// We use a password function here so the connection defaults do not
8181
// override the empty string value with one from process.env.PGPASSWORD
82-
password: () => '',
82+
password: () => '',
8383
})
8484
let usingSasl = false
8585
client.connection.once('authenticationSASL', () => {

Diff for: packages/pg/test/integration/gh-issues/3062-tests.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ suite.testAsync('result fields with the same name should pick the last value', a
88
const client = new helper.pg.Client()
99
await client.connect()
1010

11-
const { rows: [shouldBeNullRow] } = await client.query('SELECT NULL AS test, 10 AS test, NULL AS test')
11+
const {
12+
rows: [shouldBeNullRow],
13+
} = await client.query('SELECT NULL AS test, 10 AS test, NULL AS test')
1214
assert.equal(shouldBeNullRow.test, null)
1315

14-
const { rows: [shouldBeTwelveRow] } = await client.query('SELECT NULL AS test, 10 AS test, 12 AS test')
16+
const {
17+
rows: [shouldBeTwelveRow],
18+
} = await client.query('SELECT NULL AS test, 10 AS test, 12 AS test')
1519
assert.equal(shouldBeTwelveRow.test, 12)
1620

17-
const { rows: [shouldBeAbcRow] } = await client.query(`SELECT NULL AS test, 10 AS test, 12 AS test, 'ABC' AS test`)
21+
const {
22+
rows: [shouldBeAbcRow],
23+
} = await client.query(`SELECT NULL AS test, 10 AS test, 12 AS test, 'ABC' AS test`)
1824
assert.equal(shouldBeAbcRow.test, 'ABC')
1925

2026
await client.end()

Diff for: packages/pg/test/integration/gh-issues/787-tests.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ const pool = new helper.pg.Pool()
44

55
pool.connect(function (err, client) {
66
var q = {
7-
name:
8-
'This is a super long query name just so I can test that an error message is properly spit out to console.error without throwing an exception or anything',
7+
name: 'This is a super long query name just so I can test that an error message is properly spit out to console.error without throwing an exception or anything',
98
text: 'SELECT NOW()',
109
}
1110
client.query(q, function () {

Diff for: packages/pg/test/unit/client/escape-tests.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ var testLit = function (testName, input, expected) {
2020
var actual = Client.prototype.escapeLiteral(input)
2121
assert.equal(expected, actual)
2222
})
23-
24-
23+
2524
test('utils.' + testName, function () {
2625
var actual = utils.escapeLiteral(input)
2726
assert.equal(expected, actual)
@@ -39,8 +38,7 @@ var testIdent = function (testName, input, expected) {
3938
var actual = Client.prototype.escapeIdentifier(input)
4039
assert.equal(expected, actual)
4140
})
42-
43-
41+
4442
test('utils.' + testName, function () {
4543
var actual = utils.escapeIdentifier(input)
4644
assert.equal(expected, actual)

Diff for: packages/pg/test/unit/utils-tests.js

+25-5
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,17 @@ testEscapeLiteral('escapeLiteral: contains backslashes only', 'hello \\ world',
256256

257257
testEscapeLiteral('escapeLiteral: contains single quotes and double quotes', 'hello \' " world', "'hello '' \" world'")
258258

259-
testEscapeLiteral('escapeLiteral: contains double quotes and backslashes', 'hello \\ " world', " E'hello \\\\ \" world'")
259+
testEscapeLiteral(
260+
'escapeLiteral: contains double quotes and backslashes',
261+
'hello \\ " world',
262+
" E'hello \\\\ \" world'"
263+
)
260264

261-
testEscapeLiteral('escapeLiteral: contains single quotes and backslashes', "hello \\ ' world", " E'hello \\\\ '' world'")
265+
testEscapeLiteral(
266+
'escapeLiteral: contains single quotes and backslashes',
267+
"hello \\ ' world",
268+
" E'hello \\\\ '' world'"
269+
)
262270

263271
testEscapeLiteral(
264272
'escapeLiteral: contains single quotes, double quotes, and backslashes',
@@ -281,11 +289,23 @@ testEscapeIdentifier('escapeIdentifier: contains single quotes only', "hello ' w
281289

282290
testEscapeIdentifier('escapeIdentifier: contains backslashes only', 'hello \\ world', '"hello \\ world"')
283291

284-
testEscapeIdentifier('escapeIdentifier: contains single quotes and double quotes', 'hello \' " world', '"hello \' "" world"')
292+
testEscapeIdentifier(
293+
'escapeIdentifier: contains single quotes and double quotes',
294+
'hello \' " world',
295+
'"hello \' "" world"'
296+
)
285297

286-
testEscapeIdentifier('escapeIdentifier: contains double quotes and backslashes', 'hello \\ " world', '"hello \\ "" world"')
298+
testEscapeIdentifier(
299+
'escapeIdentifier: contains double quotes and backslashes',
300+
'hello \\ " world',
301+
'"hello \\ "" world"'
302+
)
287303

288-
testEscapeIdentifier('escapeIdentifier: contains single quotes and backslashes', "hello \\ ' world", '"hello \\ \' world"')
304+
testEscapeIdentifier(
305+
'escapeIdentifier: contains single quotes and backslashes',
306+
"hello \\ ' world",
307+
'"hello \\ \' world"'
308+
)
289309

290310
testEscapeIdentifier(
291311
'escapeIdentifier: contains single quotes, double quotes, and backslashes',

0 commit comments

Comments
 (0)