Enable eslint:recommended and plugin/node/recommended (#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
This commit is contained in:
Sehrope Sarkuni 2019-05-10 13:23:49 -04:00 committed by Brian C
parent 61cc3d26e2
commit 8ba1d2c572
10 changed files with 31 additions and 10 deletions

View File

@ -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"
}
}

View File

@ -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)
})
@ -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)
})

View File

@ -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 || []

View File

@ -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

View File

@ -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')

View File

@ -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)

View File

@ -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
}

View File

@ -1,3 +1,4 @@
'use strict'
const crypto = require('crypto')
function startSession (mechanisms) {

View File

@ -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",

View File

@ -76,7 +76,7 @@ class Suite {
process.on('unhandledRejection', (e) => {
setImmediate(() => {
console.error('Uhandled promise rejection')
console.error('Unhandled promise rejection')
throw e
})
})