Skip to content

Commit 3d5a79b

Browse files
committed
Please eslint
1 parent e8e86f8 commit 3d5a79b

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

lib/connection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ function Connection(options = {}) {
137137
}
138138

139139
function connect() {
140-
connect_timeout && (clearTimeout(connect_timer), connect_timer = setTimeout(connectTimedOut, connect_timeout * 1000))
140+
connect_timeout && (
141+
clearTimeout(connect_timer),
142+
connect_timer = setTimeout(connectTimedOut, connect_timeout * 1000)
143+
)
141144
socket.connect()
142145
}
143146

lib/index.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,9 @@ function Postgres(a, b) {
444444
acc + (!columns.length || columns.indexOf(k) > -1
445445
? (acc ? ',' : '') + parseValue(v, xargs, types) + ' as ' + escape(k)
446446
: ''
447-
)
448-
, '')
447+
),
448+
''
449+
)
449450
}
450451

451452
function insertHelper(first, columns, xargs, types) {
@@ -455,14 +456,16 @@ function Postgres(a, b) {
455456
first.reduce((acc, row) =>
456457
acc + (acc ? ',' : '') + '(' +
457458
columns.reduce((acc, k) => acc + (acc ? ',' : '') + parseValue(row[k], xargs, types), '') +
458-
')'
459-
, '')
459+
')',
460+
''
461+
)
460462
}
461463

462464
function equalsHelper(first, columns, xargs, types) {
463465
return (columns.length ? columns : Object.keys(first)).reduce((acc, k) =>
464-
acc + (acc ? ',' : '') + escape(k) + ' = ' + parseValue(first[k], xargs, types)
465-
, '')
466+
acc + (acc ? ',' : '') + escape(k) + ' = ' + parseValue(first[k], xargs, types),
467+
''
468+
)
466469
}
467470

468471
function escapeHelper(xs) {
@@ -476,8 +479,8 @@ function Postgres(a, b) {
476479
return Array.isArray(x)
477480
? x.reduce((acc, x) => acc + (acc ? ',' : '') + addValue(x, xargs, types), '')
478481
: x && x.P === notPromise.P
479-
? parseArg('', x, xargs, types)
480-
: addValue(x, xargs, types)
482+
? parseArg('', x, xargs, types)
483+
: addValue(x, xargs, types)
481484
}
482485

483486
function addValue(x, xargs, types) {
@@ -523,8 +526,8 @@ function parseOptions(a, b) {
523526
max : o.max || url.query.max || 10,
524527
types : o.types || {},
525528
ssl : o.ssl || url.ssl || false,
526-
idle_timeout : o.idle_timeout || url.query.idle_timeout || env.PGIDLE_TIMEOUT || warn(o.timeout, 'The timeout option is deprecated, use idle_timeout instead'),
527-
connect_timeout : o.connect_timeout || url.query.connect_timeout || env.PGCONNECT_TIMEOUT || 30,
529+
idle_timeout : o.idle_timeout || url.query.idle_timeout || env.PGIDLE_TIMEOUT || warn(o.timeout),
530+
connect_timeout : o.connect_timeout || url.query.connect_timeout || env.PGCONNECT_TIMEOUT || 30,
528531
onnotice : o.onnotice,
529532
onparameter : o.onparameter,
530533
transform : Object.assign({}, o.transform),
@@ -535,8 +538,8 @@ function parseOptions(a, b) {
535538
)
536539
}
537540

538-
function warn(x, message) {
539-
typeof x !== 'undefined' && console.log(message)
541+
function warn(x) {
542+
typeof x !== 'undefined' && console.log('The timeout option is deprecated, use idle_timeout instead') // eslint-disable-line
540543
return x
541544
}
542545

tests/index.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ t('Connection destroyed', async() => {
439439

440440
t('Connection destroyed with query before', async() => {
441441
const sql = postgres(options)
442-
let error = sql`select pg_sleep(0.2)`.catch(err => err.code)
442+
, error = sql`select pg_sleep(0.2)`.catch(err => err.code)
443+
443444
sql.end({ timeout: 0 })
444445
return ['CONNECTION_DESTROYED', await error]
445446
})
@@ -684,21 +685,30 @@ t('dynamic multi row insert', async() => {
684685
await sql`create table test (a int, b text)`
685686
const x = { a: 42, b: 'the answer' }
686687

687-
return ['the answer', (await sql`insert into test ${ sql([x, x]) } returning *`)[1].b, await sql`drop table test`]
688+
return [
689+
'the answer',
690+
(await sql`insert into test ${ sql([x, x]) } returning *`)[1].b, await sql`drop table test`
691+
]
688692
})
689693

690694
t('dynamic update', async() => {
691695
await sql`create table test (a int, b text)`
692696
await sql`insert into test (a, b) values (17, 'wrong')`
693697

694-
return ['the answer', (await sql`update test set ${ sql({ a: 42, b: 'the answer' }) } returning *`)[0].b, await sql`drop table test`]
698+
return [
699+
'the answer',
700+
(await sql`update test set ${ sql({ a: 42, b: 'the answer' }) } returning *`)[0].b, await sql`drop table test`
701+
]
695702
})
696703

697704
t('dynamic update pluck', async() => {
698705
await sql`create table test (a int, b text)`
699706
await sql`insert into test (a, b) values (17, 'wrong')`
700707

701-
return ['wrong', (await sql`update test set ${ sql({ a: 42, b: 'the answer' }, 'a') } returning *`)[0].b, await sql`drop table test`]
708+
return [
709+
'wrong',
710+
(await sql`update test set ${ sql({ a: 42, b: 'the answer' }, 'a') } returning *`)[0].b, await sql`drop table test`
711+
]
702712
})
703713

704714
t('dynamic select array', async() => {
@@ -945,8 +955,8 @@ t('Error contains query parameters', async() => [
945955
t('Query string is not enumerable', async() => {
946956
const sql = postgres({ ...options, debug: false })
947957
return [
948-
-1,
949-
(await sql`selec 1`.catch(err => Object.keys(err).indexOf('query')))
958+
-1,
959+
(await sql`selec 1`.catch(err => Object.keys(err).indexOf('query')))
950960
]
951961
})
952962

0 commit comments

Comments
 (0)