mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
eslint: enable rule: @typescript-eslint/no-unused-vars (#3247)
When enabling this rule, it's recommended to also *disable* the standard `no-unused-vars` rule. Although `no-unused-vars` is not currently enabled, it seems helpful to explicitly disable it here. See: https://typescript-eslint.io/rules/no-unused-vars/ Co-authored-by: alxndrsn <alxndrsn>
This commit is contained in:
parent
a24a24dea1
commit
83a0e3e90e
@ -1,5 +1,5 @@
|
||||
{
|
||||
"plugins": ["prettier"],
|
||||
"plugins": ["@typescript-eslint", "prettier"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"extends": ["plugin:prettier/recommended", "prettier"],
|
||||
"ignorePatterns": ["node_modules", "coverage", "packages/pg-protocol/dist/**/*", "packages/pg-query-stream/dist/**/*"],
|
||||
@ -11,5 +11,11 @@
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": ["error", {
|
||||
"args": "none"
|
||||
}],
|
||||
"no-unused-vars": "off"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
// file for microbenchmarking
|
||||
|
||||
import { Writer } from './buffer-writer'
|
||||
import { serialize } from './index'
|
||||
import { BufferReader } from './buffer-reader'
|
||||
|
||||
const LOOPS = 1000
|
||||
let count = 0
|
||||
let start = Date.now()
|
||||
const writer = new Writer()
|
||||
|
||||
const reader = new BufferReader()
|
||||
const buffer = Buffer.from([33, 33, 33, 33, 33, 33, 33, 0])
|
||||
|
||||
@ -14,17 +14,6 @@ var parseCompleteBuffer = buffers.parseComplete()
|
||||
var bindCompleteBuffer = buffers.bindComplete()
|
||||
var portalSuspendedBuffer = buffers.portalSuspended()
|
||||
|
||||
var addRow = function (bufferList: BufferList, name: string, offset: number) {
|
||||
return bufferList
|
||||
.addCString(name) // field name
|
||||
.addInt32(offset++) // table id
|
||||
.addInt16(offset++) // attribute of column number
|
||||
.addInt32(offset++) // objectId of field's data type
|
||||
.addInt16(offset++) // datatype size
|
||||
.addInt32(offset++) // type modifier
|
||||
.addInt16(0) // format code, 0 => text
|
||||
}
|
||||
|
||||
var row1 = {
|
||||
name: 'id',
|
||||
tableID: 1,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BackendMessage, DatabaseError } from './messages'
|
||||
import { DatabaseError } from './messages'
|
||||
import { serialize } from './serializer'
|
||||
import { Parser, MessageCallback } from './parser'
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ import {
|
||||
NoticeMessage,
|
||||
} from './messages'
|
||||
import { BufferReader } from './buffer-reader'
|
||||
import assert from 'assert'
|
||||
|
||||
// every message is prefixed with a single bye
|
||||
const CODE_LENGTH = 1
|
||||
|
||||
@ -122,9 +122,11 @@ if (!process.version.startsWith('v8')) {
|
||||
const pool = new pg.Pool({ max: 1 })
|
||||
const client = await pool.connect()
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
for await (const _ of client.query(new QueryStream('select TRUE', [], { highWaterMark: 1 }))) break
|
||||
for await (const _ of client.query(new QueryStream('select TRUE', [], { highWaterMark: 1 }))) break
|
||||
for await (const _ of client.query(new QueryStream('select TRUE', [], { highWaterMark: 1 }))) break
|
||||
/* eslint-enable @typescript-eslint/no-unused-vars */
|
||||
|
||||
client.release()
|
||||
await pool.end()
|
||||
|
||||
@ -2,7 +2,7 @@ import helper from './helper'
|
||||
import concat from 'concat-stream'
|
||||
import JSONStream from 'JSONStream'
|
||||
import QueryStream from '../src'
|
||||
import { Transform, TransformCallback } from 'stream'
|
||||
import { Transform } from 'stream'
|
||||
|
||||
class PauseStream extends Transform {
|
||||
constructor() {
|
||||
|
||||
@ -27,7 +27,6 @@ function getAppName(conf, cb) {
|
||||
}
|
||||
|
||||
suite.test('No default appliation_name ', function (done) {
|
||||
var conf = getConInfo()
|
||||
getAppName({}, function (res) {
|
||||
assert.strictEqual(res, '')
|
||||
done()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,7 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var helper = require('./test-helper')
|
||||
var util = require('util')
|
||||
|
||||
var pg = helper.pg
|
||||
const Client = pg.Client
|
||||
@ -113,7 +112,7 @@ var ensureFuture = function (testClient, done) {
|
||||
suite.test('when query is parsing', (done) => {
|
||||
var client = createErorrClient()
|
||||
|
||||
var q = client.query({ text: 'CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);' })
|
||||
client.query({ text: 'CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);' })
|
||||
|
||||
// this query wont parse since there isn't a table named bang
|
||||
var query = client.query(
|
||||
@ -131,7 +130,7 @@ suite.test('when query is parsing', (done) => {
|
||||
suite.test('when a query is binding', function (done) {
|
||||
var client = createErorrClient()
|
||||
|
||||
var q = client.query({ text: 'CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);' })
|
||||
client.query({ text: 'CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);' })
|
||||
|
||||
var query = client.query(
|
||||
new pg.Query({
|
||||
|
||||
@ -33,7 +33,7 @@ suite.test(
|
||||
|
||||
// TODO should be text or sql?
|
||||
try {
|
||||
const results = yield client.query({
|
||||
yield client.query({
|
||||
text: `SELECT 'foo'::text as name; SELECT 'bar'::text as baz`,
|
||||
queryMode: 'extended',
|
||||
})
|
||||
|
||||
@ -5,7 +5,7 @@ const suite = new helper.Suite()
|
||||
suite.test('noData message handling', function () {
|
||||
var client = helper.client()
|
||||
|
||||
var q = client.query({
|
||||
client.query({
|
||||
name: 'boom',
|
||||
text: 'create temp table boom(id serial, size integer)',
|
||||
})
|
||||
@ -29,7 +29,7 @@ suite.test('noData message handling', function () {
|
||||
values: [101],
|
||||
})
|
||||
|
||||
var query = client.query(
|
||||
client.query(
|
||||
{
|
||||
name: 'fetch',
|
||||
text: 'select size from boom where size < $1',
|
||||
|
||||
@ -9,7 +9,6 @@ var suite = new helper.Suite()
|
||||
client.on('drain', client.end.bind(client))
|
||||
|
||||
var queryName = 'user by age and like name'
|
||||
var parseCount = 0
|
||||
|
||||
suite.test('first named prepared statement', function (done) {
|
||||
var query = client.query(
|
||||
@ -89,7 +88,7 @@ var suite = new helper.Suite()
|
||||
var client2 = helper.client()
|
||||
|
||||
suite.test('client 1 execution', function (done) {
|
||||
var query = client1.query(
|
||||
client1.query(
|
||||
{
|
||||
name: statementName,
|
||||
text: statement1,
|
||||
|
||||
@ -19,7 +19,7 @@ new helper.Suite().test('should return insert metadata', function () {
|
||||
assert.equal(result.oid, null)
|
||||
assert.equal(result.command, 'CREATE')
|
||||
|
||||
var q = client.query(
|
||||
client.query(
|
||||
"INSERT INTO zugzug(name) VALUES('more work?')",
|
||||
assert.calls(function (err, result) {
|
||||
assert(!err)
|
||||
|
||||
@ -23,7 +23,7 @@ test('returns results as array', function () {
|
||||
values: ['hai'],
|
||||
rowMode: 'array',
|
||||
}
|
||||
var query = client.query(
|
||||
client.query(
|
||||
config,
|
||||
assert.success(function (result) {
|
||||
assert.equal(result.rows.length, 1)
|
||||
|
||||
@ -18,6 +18,7 @@ test('simple query interface', function () {
|
||||
query.once('row', function (row) {
|
||||
test('Can iterate through columns', function () {
|
||||
var columnCount = 0
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
for (var column in row) {
|
||||
columnCount++
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ var testForTypeCoercion = function (type) {
|
||||
assert(!err)
|
||||
|
||||
type.values.forEach(function (val) {
|
||||
var insertQuery = client.query(
|
||||
client.query(
|
||||
'insert into test_type(col) VALUES($1)',
|
||||
[val],
|
||||
assert.calls(function (err, result) {
|
||||
@ -135,8 +135,6 @@ if (helper.config.binary) {
|
||||
})
|
||||
}
|
||||
|
||||
var valueCount = 0
|
||||
|
||||
types.forEach(function (type) {
|
||||
testForTypeCoercion(type)
|
||||
})
|
||||
|
||||
@ -18,7 +18,6 @@ suite.test('errors emitted on checked-out clients', (cb) => {
|
||||
client.query('SELECT NOW()', function () {
|
||||
pool.connect(
|
||||
assert.success(function (client2, done2) {
|
||||
var pidColName = 'procpid'
|
||||
helper.versionGTE(
|
||||
client2,
|
||||
90200,
|
||||
|
||||
@ -4,7 +4,7 @@ var assert = require('assert')
|
||||
|
||||
test('COPY FROM events check', function () {
|
||||
helper.connect(function (con) {
|
||||
var stdinStream = con.query('COPY person FROM STDIN')
|
||||
con.query('COPY person FROM STDIN')
|
||||
con.on('copyInResponse', function () {
|
||||
con.endCopyFrom()
|
||||
})
|
||||
@ -28,7 +28,7 @@ test('COPY FROM events check', function () {
|
||||
})
|
||||
test('COPY TO events check', function () {
|
||||
helper.connect(function (con) {
|
||||
var stdoutStream = con.query('COPY person TO STDOUT')
|
||||
con.query('COPY person TO STDOUT')
|
||||
assert.emits(con, 'copyOutResponse', function () {}, 'backend should emit copyOutResponse after COPY TO query')
|
||||
assert.emits(con, 'copyData', function () {}, 'backend should emit copyData on every data row')
|
||||
assert.emits(
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
var net = require('net')
|
||||
var helper = require('../test-helper')
|
||||
var Connection = require('../../../lib/connection')
|
||||
var utils = require('../../../lib/utils')
|
||||
const crypto = require('../../../lib/crypto/utils')
|
||||
var connect = function (callback) {
|
||||
var username = helper.args.user
|
||||
|
||||
@ -29,7 +29,7 @@ suite.test('with domain', function (cb) {
|
||||
assert.success(function (client, done) {
|
||||
assert(process.domain, 'no domain exists in connect callback')
|
||||
assert.equal(startingDomain, process.domain, 'domain was lost when checking out a client')
|
||||
var query = client.query(
|
||||
client.query(
|
||||
'SELECT NOW()',
|
||||
assert.success(function () {
|
||||
assert(process.domain, 'no domain exists in query callback')
|
||||
|
||||
@ -17,6 +17,6 @@ suite.testAsync('BoundPool can be subclassed', async () => {
|
||||
suite.test('calling pg.Pool without new throws', () => {
|
||||
const Pool = helper.pg.Pool
|
||||
assert.throws(() => {
|
||||
const pool = Pool()
|
||||
Pool()
|
||||
})
|
||||
})
|
||||
|
||||
@ -25,7 +25,6 @@ suite.test('Password should not exist in util.inspect output', () => {
|
||||
suite.test('Password should not exist in json.stringfy output', () => {
|
||||
const pool = new helper.pg.Pool({ password })
|
||||
const client = new helper.pg.Client({ password })
|
||||
const depth = 20
|
||||
assert(JSON.stringify(pool).indexOf(password) === -1)
|
||||
assert(JSON.stringify(client).indexOf(password) === -1)
|
||||
})
|
||||
|
||||
@ -25,7 +25,6 @@ suite.test('SSL Key should not exist in util.inspect output', () => {
|
||||
suite.test('SSL Key should not exist in json.stringfy output', () => {
|
||||
const pool = new helper.pg.Pool({ ssl: { key: secret_value } })
|
||||
const client = new helper.pg.Client({ ssl: { key: secret_value } })
|
||||
const depth = 20
|
||||
assert(JSON.stringify(pool).indexOf(secret_value) === -1)
|
||||
assert(JSON.stringify(client).indexOf(secret_value) === -1)
|
||||
})
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
'use strict'
|
||||
var helper = require('./test-helper')
|
||||
require('./test-helper')
|
||||
var net = require('net')
|
||||
var pg = require('../../../lib/index.js')
|
||||
|
||||
|
||||
@ -90,9 +90,7 @@ test('bound command', function () {
|
||||
|
||||
var portalClient = helper.client()
|
||||
var portalCon = portalClient.connection
|
||||
var portalParseArg = null
|
||||
portalCon.parse = function (arg) {
|
||||
portalParseArg = arg
|
||||
process.nextTick(function () {
|
||||
portalCon.emit('parseComplete')
|
||||
})
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
'use strict'
|
||||
var helper = require('./test-helper')
|
||||
require('./test-helper')
|
||||
var Connection = require('../../../lib/connection')
|
||||
|
||||
test('drain', function () {
|
||||
|
||||
@ -6,7 +6,7 @@ var testForTag = function (tagText, callback) {
|
||||
var client = helper.client()
|
||||
client.connection.emit('readyForQuery')
|
||||
|
||||
var query = client.query(
|
||||
client.query(
|
||||
'whatever',
|
||||
assert.calls((err, result) => {
|
||||
assert.ok(result != null, 'should pass something to this event')
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
'use strict'
|
||||
var helper = require('./test-helper')
|
||||
require('./test-helper')
|
||||
var Connection = require('../../../lib/connection')
|
||||
var Client = require('../../../lib/client')
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@ const emitFakeEvents = (con) => {
|
||||
}
|
||||
|
||||
suite.test('emits error', function (done) {
|
||||
var handled
|
||||
var client = helper.client()
|
||||
var con = client.connection
|
||||
var query = client.query(new Query('whatever'))
|
||||
@ -45,14 +44,10 @@ suite.test('emits error', function (done) {
|
||||
})
|
||||
|
||||
suite.test('calls callback with error', function (done) {
|
||||
var handled
|
||||
|
||||
var callbackCalled = 0
|
||||
|
||||
var client = helper.client()
|
||||
var con = client.connection
|
||||
emitFakeEvents(con)
|
||||
var query = client.query('whatever', function (err) {
|
||||
client.query('whatever', function (err) {
|
||||
assert.equal(err, typeParserError)
|
||||
done()
|
||||
})
|
||||
|
||||
@ -344,7 +344,6 @@ suite.test('ssl is set on client', function () {
|
||||
sslrootcert: '/path/root.crt',
|
||||
},
|
||||
}
|
||||
var Client = require('../../../lib/client')
|
||||
var defaults = require('../../../lib/defaults')
|
||||
defaults.ssl = true
|
||||
var c = new ConnectionParameters(sourceConfig)
|
||||
|
||||
@ -183,7 +183,6 @@ test('prepareValue: Uint8Array array prepared properly', function () {
|
||||
})
|
||||
|
||||
test('prepareValue: objects with complex toPostgres prepared properly', function () {
|
||||
var buf = Buffer.from('zomgcustom!')
|
||||
var customType = {
|
||||
toPostgres: function () {
|
||||
return [1, 2]
|
||||
@ -214,7 +213,6 @@ test('prepareValue: objects with toPostgres receive prepareValue', function () {
|
||||
})
|
||||
|
||||
test('prepareValue: objects with circular toPostgres rejected', function () {
|
||||
var buf = Buffer.from('zomgcustom!')
|
||||
var customType = {
|
||||
toPostgres: function () {
|
||||
return {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user