chore: disable eslint errors for chai assertions (#11700)

* chore: disable eslint errors for chai assertions

* refactor: make `no-unused-expressions` an error and fix code
This commit is contained in:
Lucian Mocanu 2025-10-01 23:21:13 +02:00 committed by GitHub
parent a7c387bc14
commit b1680a04ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 114 additions and 56 deletions

View File

@ -1,19 +1,18 @@
import eslint from "@eslint/js"
import pluginChaiFriendly from "eslint-plugin-chai-friendly"
import { jsdoc } from "eslint-plugin-jsdoc"
import tseslint from "typescript-eslint"
import { defineConfig, globalIgnores } from "eslint/config"
import globals from "globals"
import tseslint from "typescript-eslint"
export default tseslint.config([
{
ignores: [
"build/**",
"docs/**",
"node_modules/**",
"sample/playground/**",
"temp/**",
],
},
export default defineConfig([
globalIgnores([
"build/**",
"docs/**",
"node_modules/**",
"sample/playground/**",
"temp/**",
]),
{
files: ["**/*.ts"],
languageOptions: {
@ -40,7 +39,6 @@ export default tseslint.config([
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
"@typescript-eslint/no-unsafe-function-type": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
@ -82,9 +80,12 @@ export default tseslint.config([
"no-regex-spaces": "warn",
},
},
jsdoc({
config: 'flat/recommended-typescript', // change to 'flat/recommended-typescript-error' once warnings are fixed
files: ["src/**/*.ts"],
config: "flat/recommended-typescript", // change to 'flat/recommended-typescript-error' once warnings are fixed
}),
{
files: ["test/**/*.ts"],
...pluginChaiFriendly.configs.recommendedFlat,
},
])

40
package-lock.json generated
View File

@ -52,7 +52,8 @@
"chai-as-promised": "^8.0.2",
"class-transformer": "^0.5.1",
"eslint": "^9.36.0",
"eslint-plugin-jsdoc": "^60.6.0",
"eslint-plugin-chai-friendly": "^1.1.0",
"eslint-plugin-jsdoc": "^60.7.0",
"globals": "^16.4.0",
"gulp": "^4.0.2",
"gulp-rename": "^2.1.0",
@ -837,17 +838,17 @@
}
},
"node_modules/@es-joy/jsdoccomment": {
"version": "0.64.0",
"resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.64.0.tgz",
"integrity": "sha512-sLUv/udfqNO795T0dHAgV6kC79VJvUfX3kDw/F24+dVvGL25QQfxWLTrNjIZ3BcD8R/c8Hg3inC0GrXXTSw4/A==",
"version": "0.65.2",
"resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.65.2.tgz",
"integrity": "sha512-/rrj5oayCc7xdoQZ24Tz/+V41IDm+9ILYpTFJOZgav9vfncMNApKR0t/4d1oRXYTcyLZEcGHGOg4xBsD0Doing==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "^1.0.8",
"@typescript-eslint/types": "^8.44.1",
"@typescript-eslint/types": "^8.45.0",
"comment-parser": "1.4.1",
"esquery": "^1.6.0",
"jsdoc-type-pratt-parser": "~6.0.0"
"jsdoc-type-pratt-parser": "~6.1.2"
},
"engines": {
"node": ">=20.11.0"
@ -6377,14 +6378,27 @@
}
}
},
"node_modules/eslint-plugin-chai-friendly": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-1.1.0.tgz",
"integrity": "sha512-+T1rClpDdXkgBAhC16vRQMI5umiWojVqkj9oUTdpma50+uByCZM/oBfxitZiOkjMRlm725mwFfz/RVgyDRvCKA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
},
"peerDependencies": {
"eslint": ">=3.0.0"
}
},
"node_modules/eslint-plugin-jsdoc": {
"version": "60.6.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-60.6.0.tgz",
"integrity": "sha512-1+p0342+nNIrQzsu6Tw6W89a/LKAdmpCKLx0LsLibEIx93NfgvzUbtLmw7gUoV4egRx0iNv+rM/iiG8f4WxLHA==",
"version": "60.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-60.7.0.tgz",
"integrity": "sha512-y1AYoLoWNIOzjctcem9MjIZb9XDoTBI6D9lyaWT0W8/t6jpNvTuMQJljRzaQyjTDDFbONAEcuufdu0DXtCUP8A==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"@es-joy/jsdoccomment": "~0.64.0",
"@es-joy/jsdoccomment": "~0.65.2",
"are-docs-informative": "^0.0.2",
"comment-parser": "1.4.1",
"debug": "^4.4.3",
@ -9709,9 +9723,9 @@
}
},
"node_modules/jsdoc-type-pratt-parser": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-6.0.1.tgz",
"integrity": "sha512-N2OCUHYmrEPSH3SDKvbri9gAsOvhyJ01142dRb2gnpOGjBqGkUI5r6EcFSVXtLPUoUFTuh/TYMHTIEGpobqT5w==",
"version": "6.1.2",
"resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-6.1.2.tgz",
"integrity": "sha512-ruy+JcplsWkqnYq1m/qokaErhEURwf/vhdTzlPNpei7RJabVWxPxGWoCPSCP0sbsz03d590hTkjLdXjyMxH0iA==",
"dev": true,
"license": "MIT",
"engines": {

View File

@ -132,7 +132,8 @@
"chai-as-promised": "^8.0.2",
"class-transformer": "^0.5.1",
"eslint": "^9.36.0",
"eslint-plugin-jsdoc": "^60.6.0",
"eslint-plugin-chai-friendly": "^1.1.0",
"eslint-plugin-jsdoc": "^60.7.0",
"globals": "^16.4.0",
"gulp": "^4.0.2",
"gulp-rename": "^2.1.0",

View File

@ -802,14 +802,20 @@ export class AuroraMysqlDriver implements Driver {
this.poolCluster.getConnection(
"MASTER",
(err: any, dbConnection: any) => {
err
? fail(err)
: ok(this.prepareDbConnection(dbConnection))
if (err) {
fail(err)
} else {
ok(this.prepareDbConnection(dbConnection))
}
},
)
} else if (this.pool) {
this.pool.getConnection((err: any, dbConnection: any) => {
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
if (err) {
fail(err)
} else {
ok(this.prepareDbConnection(dbConnection))
}
})
} else {
fail(
@ -833,7 +839,11 @@ export class AuroraMysqlDriver implements Driver {
this.poolCluster.getConnection(
"SLAVE*",
(err: any, dbConnection: any) => {
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
if (err) {
fail(err)
} else {
ok(this.prepareDbConnection(dbConnection))
}
},
)
})

View File

@ -822,7 +822,11 @@ export class CockroachDriver implements Driver {
return new Promise((ok, fail) => {
this.master.connect((err: any, connection: any, release: any) => {
err ? fail(err) : ok([connection, release])
if (err) {
fail(err)
} else {
ok([connection, release])
}
})
})
}
@ -840,7 +844,11 @@ export class CockroachDriver implements Driver {
return new Promise((ok, fail) => {
this.slaves[random].connect(
(err: any, connection: any, release: any) => {
err ? fail(err) : ok([connection, release])
if (err) {
fail(err)
} else {
ok([connection, release])
}
},
)
})

View File

@ -912,14 +912,20 @@ export class MysqlDriver implements Driver {
this.poolCluster.getConnection(
"MASTER",
(err: any, dbConnection: any) => {
err
? fail(err)
: ok(this.prepareDbConnection(dbConnection))
if (err) {
fail(err)
} else {
ok(this.prepareDbConnection(dbConnection))
}
},
)
} else if (this.pool) {
this.pool.getConnection((err: any, dbConnection: any) => {
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
if (err) {
fail(err)
} else {
ok(this.prepareDbConnection(dbConnection))
}
})
} else {
fail(
@ -943,7 +949,11 @@ export class MysqlDriver implements Driver {
this.poolCluster.getConnection(
"SLAVE*",
(err: any, dbConnection: any) => {
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
if (err) {
fail(err)
} else {
ok(this.prepareDbConnection(dbConnection))
}
},
)
})

View File

@ -986,14 +986,16 @@ export class OracleDriver implements Driver {
try {
const oracle = this.options.driver || PlatformTools.load("oracledb")
this.oracle = oracle
} catch (e) {
} catch {
throw new DriverPackageNotInstalledError("Oracle", "oracledb")
}
const thickMode = this.options.thickMode
if (thickMode) {
typeof thickMode === "object"
? this.oracle.initOracleClient(thickMode)
: this.oracle.initOracleClient()
if (typeof thickMode === "object") {
this.oracle.initOracleClient(thickMode)
} else {
this.oracle.initOracleClient()
}
}
}

View File

@ -1210,7 +1210,11 @@ export class PostgresDriver implements Driver {
return new Promise((ok, fail) => {
this.master.connect((err: any, connection: any, release: any) => {
err ? fail(err) : ok([connection, release])
if (err) {
fail(err)
} else {
ok([connection, release])
}
})
})
}
@ -1230,7 +1234,11 @@ export class PostgresDriver implements Driver {
return new Promise((ok, fail) => {
this.slaves[random].connect(
(err: any, connection: any, release: any) => {
err ? fail(err) : ok([connection, release])
if (err) {
fail(err)
} else {
ok([connection, release])
}
},
)
})
@ -1561,14 +1569,17 @@ export class PostgresDriver implements Driver {
if (options.logNotifications) {
connection.on("notice", (msg: any) => {
msg && this.connection.logger.log("info", msg.message)
if (msg) {
this.connection.logger.log("info", msg.message)
}
})
connection.on("notification", (msg: any) => {
msg &&
if (msg) {
this.connection.logger.log(
"info",
`Received NOTIFY on channel ${msg.channel}: ${msg.payload}.`,
)
}
})
}
release()

View File

@ -138,13 +138,14 @@ describe("query builder > distinct on", () => {
expect(
result.map(({ moderator }) => moderator),
).to.have.members(["Dion", "Sarah", "Dion", "Dion"]) &&
expect(result.map(({ author }) => author)).to.have.members([
"Dion",
"Pablo",
"Sarah",
"Zelda",
])
).to.have.members(["Dion", "Sarah", "Dion", "Dion"])
expect(result.map(({ author }) => author)).to.have.members([
"Dion",
"Pablo",
"Sarah",
"Zelda",
])
}),
))