Skip to content

Commit

Permalink
Enable eslint:recommended and plugin/node/recommended (#1856)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sehrope authored and brianc committed May 10, 2019
1 parent 61cc3d2 commit 8ba1d2c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 10 deletions.
16 changes: 14 additions & 2 deletions .eslintrc
@@ -1,6 +1,18 @@
{
"extends": "standard",
"plugins": [
"node"
],
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"parserOptions": {
"ecmaVersion": 2017
},
"env": {
"node": true,
"es6": true
},
"rules": {
"no-new-func": "off"
}
}
6 changes: 5 additions & 1 deletion lib/client.js
Expand Up @@ -292,11 +292,13 @@ Client.prototype._attachListeners = function (con) {
})

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

// deletagate emptyQuery to active query
// delegate emptyQuery to active query
// eslint-disable-next-line no-unused-vars
con.on('emptyQuery', function (msg) {
self.activeQuery.handleEmptyQuery(con)
})
Expand All @@ -309,12 +311,14 @@ Client.prototype._attachListeners = function (con) {
// if a prepared statement has a name and properly parses
// we track that its already been executed so we don't parse
// it again on the same client
// eslint-disable-next-line no-unused-vars
con.on('parseComplete', function (msg) {
if (self.activeQuery.name) {
con.parsedStatements[self.activeQuery.name] = self.activeQuery.text
}
})

// eslint-disable-next-line no-unused-vars
con.on('copyInResponse', function (msg) {
self.activeQuery.handleCopyInResponse(self.connection)
})
Expand Down
4 changes: 3 additions & 1 deletion lib/connection.js
Expand Up @@ -237,9 +237,11 @@ Connection.prototype.parse = function (query, more) {
// normalize missing query names to allow for null
query.name = query.name || ''
if (query.name.length > 63) {
/* eslint-disable no-console */
console.error('Warning! Postgres only supports 63 characters for query names.')
console.error('You supplied', query.name, '(', query.name.length, ')')
console.error('You supplied %s (%s)', query.name, query.name.length)
console.error('This can cause conflicts and silent errors executing queries')
/* eslint-enable no-console */
}
// normalize null type array
query.types = query.types || []
Expand Down
2 changes: 2 additions & 0 deletions lib/index.js
Expand Up @@ -49,7 +49,9 @@ if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
if (err.code !== 'MODULE_NOT_FOUND') {
throw err
}
/* eslint-disable no-console */
console.error(err.message)
/* eslint-enable no-console */
}
module.exports.native = native
return native
Expand Down
1 change: 1 addition & 0 deletions lib/native/client.js
Expand Up @@ -7,6 +7,7 @@
* README.md file in the root directory of this source tree.
*/

// eslint-disable-next-line node/no-missing-require
var Native = require('pg-native')
var TypeOverrides = require('../type-overrides')
var semver = require('semver')
Expand Down
4 changes: 3 additions & 1 deletion lib/native/query.js
Expand Up @@ -130,9 +130,11 @@ NativeQuery.prototype.submit = function (client) {
// named query
if (this.name) {
if (this.name.length > 63) {
/* eslint-disable no-console */
console.error('Warning! Postgres only supports 63 characters for query names.')
console.error('You supplied', this.name, '(', this.name.length, ')')
console.error('You supplied %s (%s)', this.name, this.name.length)
console.error('This can cause conflicts and silent errors executing queries')
/* eslint-enable no-console */
}
var values = (this.values || []).map(utils.prepareValue)

Expand Down
1 change: 1 addition & 0 deletions lib/query.js
Expand Up @@ -222,6 +222,7 @@ Query.prototype.handleCopyInResponse = function (connection) {
connection.sendCopyFail('No source stream defined')
}

// eslint-disable-next-line no-unused-vars
Query.prototype.handleCopyData = function (msg, connection) {
// noop
}
Expand Down
1 change: 1 addition & 0 deletions lib/sasl.js
@@ -1,3 +1,4 @@
'use strict'
const crypto = require('crypto')

function startSession (mechanisms) {
Expand Down
4 changes: 0 additions & 4 deletions package.json
Expand Up @@ -32,11 +32,7 @@
"bluebird": "3.5.2",
"co": "4.6.0",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^3.1.0",
"pg-copy-streams": "0.3.0"
},
"minNativeVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test/suite.js
Expand Up @@ -76,7 +76,7 @@ class Suite {

process.on('unhandledRejection', (e) => {
setImmediate(() => {
console.error('Uhandled promise rejection')
console.error('Unhandled promise rejection')
throw e
})
})
Expand Down

0 comments on commit 8ba1d2c

Please sign in to comment.