Skip to content

chore: re-enable no-unused vars eslint rule and align to ts #3445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
},
"rules": {
"@typescript-eslint/no-unused-vars": ["error", {
"args": "none"
"args": "none",
"varsIgnorePattern": "^_$"
}],
"no-unused-vars": ["error", {
"args": "none",
"varsIgnorePattern": "^_$"
}],
"no-unused-vars": "off",
"no-var": "error",
"prefer-const": "error"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-native/test/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const checkDomain = function (domain, when) {

describe('domains', function () {
it('remains bound after a query', function (done) {
var domain = require('domain').create() // eslint-disable-line
const domain = require('domain').create()
domain.run(function () {
const client = new Client()
client.connect(function () {
Expand Down
2 changes: 0 additions & 2 deletions packages/pg-protocol/src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ const parse = (query: ParseOpts): Buffer => {
// normalize missing query names to allow for null
const name = query.name || ''
if (name.length > 63) {
/* eslint-disable no-console */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe no-console should be enabled instead?

Copy link
Contributor Author

@DavideViolante DavideViolante Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to enable now and there are 80+ errors in the following files:

/node-postgres/packages/pg-cloudflare/src/index.ts
/node-postgres/packages/pg-native/bench/index.js
/node-postgres/packages/pg-native/bench/leaks.js
/node-postgres/packages/pg-native/test/query-async.js
/node-postgres/packages/pg-pool/test/error-handling.js
/node-postgres/packages/pg-pool/test/idle-timeout-exit.js
/node-postgres/packages/pg-pool/test/lifetime-timeout.js
/node-postgres/packages/pg-pool/test/setup.js
/node-postgres/packages/pg-protocol/src/b.ts
/node-postgres/packages/pg-protocol/src/serializer.ts
/node-postgres/packages/pg-query-stream/test/close.ts
/node-postgres/packages/pg-query-stream/test/error.ts
/node-postgres/packages/pg/bench.js
/node-postgres/packages/pg/lib/native/query.js
/node-postgres/packages/pg/script/create-test-tables.js
/node-postgres/packages/pg/script/dump-db-types.js
/node-postgres/packages/pg/test/integration/client/api-tests.js
/node-postgres/packages/pg/test/integration/client/array-tests.js
/node-postgres/packages/pg/test/integration/client/async-stack-trace-tests.js
/node-postgres/packages/pg/test/integration/client/big-simple-query-tests.js
/node-postgres/packages/pg/test/integration/client/idle_in_transaction_session_timeout-tests.js
/node-postgres/packages/pg/test/integration/client/json-type-parsing-tests.js
/node-postgres/packages/pg/test/integration/client/no-data-tests.js
/node-postgres/packages/pg/test/integration/client/notice-tests.js
/node-postgres/packages/pg/test/integration/client/query-as-promise-tests.js
/node-postgres/packages/pg/test/integration/client/query-error-handling-tests.js
/node-postgres/packages/pg/test/integration/client/type-coercion-tests.js
/node-postgres/packages/pg/test/integration/gh-issues/131-tests.js
/node-postgres/packages/pg/test/suite.js
/node-postgres/packages/pg/test/test-helper.js

Most of them are tests, but some are not, like this file (serializer). I think most of these logs are useful.

console.error('Warning! Postgres only supports 63 characters for query names.')
console.error('You supplied %s (%s)', name, name.length)
console.error('This can cause conflicts and silent errors executing queries')
/* eslint-enable no-console */
}

const types = query.types || emptyArray
Expand Down
2 changes: 0 additions & 2 deletions packages/pg-query-stream/test/async-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ 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()
Expand Down
3 changes: 0 additions & 3 deletions packages/pg/lib/native/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const NativeQuery = (module.exports = function (config, values, callback) {
util.inherits(NativeQuery, EventEmitter)

const errorFieldMap = {
/* eslint-disable quote-props */
sqlState: 'code',
statementPosition: 'position',
messagePrimary: 'message',
Expand Down Expand Up @@ -130,11 +129,9 @@ 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 %s (%s)', this.name, this.name.length)
console.error('This can cause conflicts and silent errors executing queries')
/* eslint-enable no-console */
}
const values = (this.values || []).map(utils.prepareValue)

Expand Down
1 change: 0 additions & 1 deletion packages/pg/lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ class Query extends EventEmitter {
connection.sendCopyFail('No source stream defined')
}

// eslint-disable-next-line no-unused-vars
handleCopyData(msg, connection) {
// noop
}
Expand Down
6 changes: 1 addition & 5 deletions packages/pg/test/integration/client/simple-query-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ test('simple query interface', function () {
})
query.once('row', function (row) {
test('Can iterate through columns', function () {
let columnCount = 0
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const column in row) {
columnCount++
}
const columnCount = Object.keys(row).length
if ('length' in row) {
assert.lengthIs(
row,
Expand Down