Skip to content

Commit 8ba1d2c

Browse files
sehropebrianc
authored andcommitted
Enable eslint:recommended and plugin/node/recommended (brianc#1856)
* Fix typo * Enable eslint:recommended and remove unused eslint plugins Enables eslint:recommended by disabling the options that would not pass. Also removes dependencies for included but unused eslint plugins. * Convert console.error(...) calls to use %s placeholders * Enable eslint no-console rule * Add and enable eslint-node-plugin * Correct typo * Enable eslint no-unused-vars
1 parent 61cc3d2 commit 8ba1d2c

File tree

10 files changed

+31
-10
lines changed

10 files changed

+31
-10
lines changed

.eslintrc

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
2-
"extends": "standard",
2+
"plugins": [
3+
"node"
4+
],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:node/recommended"
8+
],
9+
"parserOptions": {
10+
"ecmaVersion": 2017
11+
},
12+
"env": {
13+
"node": true,
14+
"es6": true
15+
},
316
"rules": {
4-
"no-new-func": "off"
517
}
618
}

lib/client.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,13 @@ Client.prototype._attachListeners = function (con) {
292292
})
293293

294294
// delegate portalSuspended to active query
295+
// eslint-disable-next-line no-unused-vars
295296
con.on('portalSuspended', function (msg) {
296297
self.activeQuery.handlePortalSuspended(con)
297298
})
298299

299-
// deletagate emptyQuery to active query
300+
// delegate emptyQuery to active query
301+
// eslint-disable-next-line no-unused-vars
300302
con.on('emptyQuery', function (msg) {
301303
self.activeQuery.handleEmptyQuery(con)
302304
})
@@ -309,12 +311,14 @@ Client.prototype._attachListeners = function (con) {
309311
// if a prepared statement has a name and properly parses
310312
// we track that its already been executed so we don't parse
311313
// it again on the same client
314+
// eslint-disable-next-line no-unused-vars
312315
con.on('parseComplete', function (msg) {
313316
if (self.activeQuery.name) {
314317
con.parsedStatements[self.activeQuery.name] = self.activeQuery.text
315318
}
316319
})
317320

321+
// eslint-disable-next-line no-unused-vars
318322
con.on('copyInResponse', function (msg) {
319323
self.activeQuery.handleCopyInResponse(self.connection)
320324
})

lib/connection.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ Connection.prototype.parse = function (query, more) {
237237
// normalize missing query names to allow for null
238238
query.name = query.name || ''
239239
if (query.name.length > 63) {
240+
/* eslint-disable no-console */
240241
console.error('Warning! Postgres only supports 63 characters for query names.')
241-
console.error('You supplied', query.name, '(', query.name.length, ')')
242+
console.error('You supplied %s (%s)', query.name, query.name.length)
242243
console.error('This can cause conflicts and silent errors executing queries')
244+
/* eslint-enable no-console */
243245
}
244246
// normalize null type array
245247
query.types = query.types || []

lib/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
4949
if (err.code !== 'MODULE_NOT_FOUND') {
5050
throw err
5151
}
52+
/* eslint-disable no-console */
5253
console.error(err.message)
54+
/* eslint-enable no-console */
5355
}
5456
module.exports.native = native
5557
return native

lib/native/client.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* README.md file in the root directory of this source tree.
88
*/
99

10+
// eslint-disable-next-line node/no-missing-require
1011
var Native = require('pg-native')
1112
var TypeOverrides = require('../type-overrides')
1213
var semver = require('semver')

lib/native/query.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ NativeQuery.prototype.submit = function (client) {
130130
// named query
131131
if (this.name) {
132132
if (this.name.length > 63) {
133+
/* eslint-disable no-console */
133134
console.error('Warning! Postgres only supports 63 characters for query names.')
134-
console.error('You supplied', this.name, '(', this.name.length, ')')
135+
console.error('You supplied %s (%s)', this.name, this.name.length)
135136
console.error('This can cause conflicts and silent errors executing queries')
137+
/* eslint-enable no-console */
136138
}
137139
var values = (this.values || []).map(utils.prepareValue)
138140

lib/query.js

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ Query.prototype.handleCopyInResponse = function (connection) {
222222
connection.sendCopyFail('No source stream defined')
223223
}
224224

225+
// eslint-disable-next-line no-unused-vars
225226
Query.prototype.handleCopyData = function (msg, connection) {
226227
// noop
227228
}

lib/sasl.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict'
12
const crypto = require('crypto')
23

34
function startSession (mechanisms) {

package.json

-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@
3232
"bluebird": "3.5.2",
3333
"co": "4.6.0",
3434
"eslint": "^4.19.1",
35-
"eslint-config-standard": "^11.0.0",
36-
"eslint-plugin-import": "^2.14.0",
3735
"eslint-plugin-node": "^6.0.1",
38-
"eslint-plugin-promise": "^4.0.1",
39-
"eslint-plugin-standard": "^3.1.0",
4036
"pg-copy-streams": "0.3.0"
4137
},
4238
"minNativeVersion": "2.0.0",

test/suite.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Suite {
7676

7777
process.on('unhandledRejection', (e) => {
7878
setImmediate(() => {
79-
console.error('Uhandled promise rejection')
79+
console.error('Unhandled promise rejection')
8080
throw e
8181
})
8282
})

0 commit comments

Comments
 (0)