Skip to content

Commit 8591d94

Browse files
committed
Re-upgrade to prettier@2.x
1 parent 6353aff commit 8591d94

File tree

136 files changed

+1415
-1559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1415
-1559
lines changed

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test": "yarn lerna exec yarn test",
1414
"build": "yarn lerna exec --scope pg-protocol yarn build",
1515
"pretest": "yarn build",
16-
"lint": "eslint '*/**/*.{js,ts,tsx}'"
16+
"lint": "!([[ -e node_modules/.bin/prettier ]]) || eslint '*/**/*.{js,ts,tsx}'"
1717
},
1818
"devDependencies": {
1919
"@typescript-eslint/eslint-plugin": "^2.27.0",
@@ -22,8 +22,10 @@
2222
"eslint-config-prettier": "^6.10.1",
2323
"eslint-plugin-node": "^11.1.0",
2424
"eslint-plugin-prettier": "^3.1.2",
25-
"lerna": "^3.19.0",
26-
"prettier": "1.19.1"
25+
"lerna": "^3.19.0"
26+
},
27+
"optionalDependencies": {
28+
"prettier": "2.0.4"
2729
},
2830
"prettier": {
2931
"semi": false,

packages/pg-cursor/index.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ function Cursor(text, values, config) {
2525

2626
util.inherits(Cursor, EventEmitter)
2727

28-
Cursor.prototype._ifNoData = function() {
28+
Cursor.prototype._ifNoData = function () {
2929
this.state = 'idle'
3030
this._shiftQueue()
3131
}
3232

33-
Cursor.prototype._rowDescription = function() {
33+
Cursor.prototype._rowDescription = function () {
3434
if (this.connection) {
3535
this.connection.removeListener('noData', this._ifNoData)
3636
}
3737
}
3838

39-
Cursor.prototype.submit = function(connection) {
39+
Cursor.prototype.submit = function (connection) {
4040
this.connection = connection
4141
this._portal = 'C_' + nextUniqueID++
4242

@@ -75,13 +75,13 @@ Cursor.prototype.submit = function(connection) {
7575
con.once('rowDescription', this._rowDescription)
7676
}
7777

78-
Cursor.prototype._shiftQueue = function() {
78+
Cursor.prototype._shiftQueue = function () {
7979
if (this._queue.length) {
8080
this._getRows.apply(this, this._queue.shift())
8181
}
8282
}
8383

84-
Cursor.prototype._closePortal = function() {
84+
Cursor.prototype._closePortal = function () {
8585
// because we opened a named portal to stream results
8686
// we need to close the same named portal. Leaving a named portal
8787
// open can lock tables for modification if inside a transaction.
@@ -90,19 +90,19 @@ Cursor.prototype._closePortal = function() {
9090
this.connection.sync()
9191
}
9292

93-
Cursor.prototype.handleRowDescription = function(msg) {
93+
Cursor.prototype.handleRowDescription = function (msg) {
9494
this._result.addFields(msg.fields)
9595
this.state = 'idle'
9696
this._shiftQueue()
9797
}
9898

99-
Cursor.prototype.handleDataRow = function(msg) {
99+
Cursor.prototype.handleDataRow = function (msg) {
100100
const row = this._result.parseRow(msg.fields)
101101
this.emit('row', row, this._result)
102102
this._rows.push(row)
103103
}
104104

105-
Cursor.prototype._sendRows = function() {
105+
Cursor.prototype._sendRows = function () {
106106
this.state = 'idle'
107107
setImmediate(() => {
108108
const cb = this._cb
@@ -118,26 +118,26 @@ Cursor.prototype._sendRows = function() {
118118
})
119119
}
120120

121-
Cursor.prototype.handleCommandComplete = function(msg) {
121+
Cursor.prototype.handleCommandComplete = function (msg) {
122122
this._result.addCommandComplete(msg)
123123
this._closePortal()
124124
}
125125

126-
Cursor.prototype.handlePortalSuspended = function() {
126+
Cursor.prototype.handlePortalSuspended = function () {
127127
this._sendRows()
128128
}
129129

130-
Cursor.prototype.handleReadyForQuery = function() {
130+
Cursor.prototype.handleReadyForQuery = function () {
131131
this._sendRows()
132132
this.state = 'done'
133133
this.emit('end', this._result)
134134
}
135135

136-
Cursor.prototype.handleEmptyQuery = function() {
136+
Cursor.prototype.handleEmptyQuery = function () {
137137
this.connection.sync()
138138
}
139139

140-
Cursor.prototype.handleError = function(msg) {
140+
Cursor.prototype.handleError = function (msg) {
141141
this.connection.removeListener('noData', this._ifNoData)
142142
this.connection.removeListener('rowDescription', this._rowDescription)
143143
this.state = 'error'
@@ -159,7 +159,7 @@ Cursor.prototype.handleError = function(msg) {
159159
this.connection.sync()
160160
}
161161

162-
Cursor.prototype._getRows = function(rows, cb) {
162+
Cursor.prototype._getRows = function (rows, cb) {
163163
this.state = 'busy'
164164
this._cb = cb
165165
this._rows = []
@@ -173,15 +173,15 @@ Cursor.prototype._getRows = function(rows, cb) {
173173

174174
// users really shouldn't be calling 'end' here and terminating a connection to postgres
175175
// via the low level connection.end api
176-
Cursor.prototype.end = util.deprecate(function(cb) {
176+
Cursor.prototype.end = util.deprecate(function (cb) {
177177
if (this.state !== 'initialized') {
178178
this.connection.sync()
179179
}
180180
this.connection.once('end', cb)
181181
this.connection.end()
182182
}, 'Cursor.end is deprecated. Call end on the client itself to end a connection to the database.')
183183

184-
Cursor.prototype.close = function(cb) {
184+
Cursor.prototype.close = function (cb) {
185185
if (!this.connection || this.state === 'done') {
186186
if (cb) {
187187
return setImmediate(cb)
@@ -192,13 +192,13 @@ Cursor.prototype.close = function(cb) {
192192
this._closePortal()
193193
this.state = 'done'
194194
if (cb) {
195-
this.connection.once('readyForQuery', function() {
195+
this.connection.once('readyForQuery', function () {
196196
cb()
197197
})
198198
}
199199
}
200200

201-
Cursor.prototype.read = function(rows, cb) {
201+
Cursor.prototype.read = function (rows, cb) {
202202
if (this.state === 'idle') {
203203
return this._getRows(rows, cb)
204204
}

packages/pg-cursor/test/close.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,51 @@ const Cursor = require('../')
33
const pg = require('pg')
44

55
const text = 'SELECT generate_series as num FROM generate_series(0, 50)'
6-
describe('close', function() {
7-
beforeEach(function(done) {
6+
describe('close', function () {
7+
beforeEach(function (done) {
88
const client = (this.client = new pg.Client())
99
client.connect(done)
1010
})
1111

12-
this.afterEach(function(done) {
12+
this.afterEach(function (done) {
1313
this.client.end(done)
1414
})
1515

16-
it('can close a finished cursor without a callback', function(done) {
16+
it('can close a finished cursor without a callback', function (done) {
1717
const cursor = new Cursor(text)
1818
this.client.query(cursor)
1919
this.client.query('SELECT NOW()', done)
20-
cursor.read(100, function(err) {
20+
cursor.read(100, function (err) {
2121
assert.ifError(err)
2222
cursor.close()
2323
})
2424
})
2525

26-
it('closes cursor early', function(done) {
26+
it('closes cursor early', function (done) {
2727
const cursor = new Cursor(text)
2828
this.client.query(cursor)
2929
this.client.query('SELECT NOW()', done)
30-
cursor.read(25, function(err) {
30+
cursor.read(25, function (err) {
3131
assert.ifError(err)
3232
cursor.close()
3333
})
3434
})
3535

36-
it('works with callback style', function(done) {
36+
it('works with callback style', function (done) {
3737
const cursor = new Cursor(text)
3838
const client = this.client
3939
client.query(cursor)
40-
cursor.read(25, function(err, rows) {
40+
cursor.read(25, function (err, rows) {
4141
assert.ifError(err)
4242
assert.strictEqual(rows.length, 25)
43-
cursor.close(function(err) {
43+
cursor.close(function (err) {
4444
assert.ifError(err)
4545
client.query('SELECT NOW()', done)
4646
})
4747
})
4848
})
4949

50-
it('is a no-op to "close" the cursor before submitting it', function(done) {
50+
it('is a no-op to "close" the cursor before submitting it', function (done) {
5151
const cursor = new Cursor(text)
5252
cursor.close(done)
5353
})

packages/pg-cursor/test/error-handling.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ const pg = require('pg')
55

66
const text = 'SELECT generate_series as num FROM generate_series(0, 4)'
77

8-
describe('error handling', function() {
9-
it('can continue after error', function(done) {
8+
describe('error handling', function () {
9+
it('can continue after error', function (done) {
1010
const client = new pg.Client()
1111
client.connect()
1212
const cursor = client.query(new Cursor('asdfdffsdf'))
13-
cursor.read(1, function(err) {
13+
cursor.read(1, function (err) {
1414
assert(err)
15-
client.query('SELECT NOW()', function(err) {
15+
client.query('SELECT NOW()', function (err) {
1616
assert.ifError(err)
1717
client.end()
1818
done()
@@ -27,11 +27,11 @@ describe('read callback does not fire sync', () => {
2727
client.connect()
2828
const cursor = client.query(new Cursor('asdfdffsdf'))
2929
let after = false
30-
cursor.read(1, function(err) {
30+
cursor.read(1, function (err) {
3131
assert(err, 'error should be returned')
3232
assert.strictEqual(after, true, 'should not call read sync')
3333
after = false
34-
cursor.read(1, function(err) {
34+
cursor.read(1, function (err) {
3535
assert(err, 'error should be returned')
3636
assert.strictEqual(after, true, 'should not call read sync')
3737
client.end()
@@ -47,13 +47,13 @@ describe('read callback does not fire sync', () => {
4747
client.connect()
4848
const cursor = client.query(new Cursor('SELECT NOW()'))
4949
let after = false
50-
cursor.read(1, function(err) {
50+
cursor.read(1, function (err) {
5151
assert(!err)
5252
assert.strictEqual(after, true, 'should not call read sync')
53-
cursor.read(1, function(err) {
53+
cursor.read(1, function (err) {
5454
assert(!err)
5555
after = false
56-
cursor.read(1, function(err) {
56+
cursor.read(1, function (err) {
5757
assert(!err)
5858
assert.strictEqual(after, true, 'should not call read sync')
5959
client.end()
@@ -66,16 +66,16 @@ describe('read callback does not fire sync', () => {
6666
})
6767
})
6868

69-
describe('proper cleanup', function() {
70-
it('can issue multiple cursors on one client', function(done) {
69+
describe('proper cleanup', function () {
70+
it('can issue multiple cursors on one client', function (done) {
7171
const client = new pg.Client()
7272
client.connect()
7373
const cursor1 = client.query(new Cursor(text))
74-
cursor1.read(8, function(err, rows) {
74+
cursor1.read(8, function (err, rows) {
7575
assert.ifError(err)
7676
assert.strictEqual(rows.length, 5)
7777
const cursor2 = client.query(new Cursor(text))
78-
cursor2.read(8, function(err, rows) {
78+
cursor2.read(8, function (err, rows) {
7979
assert.ifError(err)
8080
assert.strictEqual(rows.length, 5)
8181
client.end()

0 commit comments

Comments
 (0)