Skip to content

chore: disable eslint errors for chai assertions - #11833

Merged
alumni merged 1 commit into
typeorm:masterfrom
alumni:chore/chai-eslint-plugin
Dec 8, 2025
Merged

alumni merged 1 commit into
typeorm:masterfrom
alumni:chore/chai-eslint-plugin

Conversation

@alumni

@alumni alumni commented Dec 8, 2025

Copy link
Copy Markdown
Collaborator

Description of change

Cherry pick of #11700 to the master branch.

Currently we set @typescript-eslint/no-unused-expressions to warn, which highlights a lot of errors in our chai assertions. When using both styles of assertion ("expect" and "should"), chai has side-effects which eslint is trying to prevent with this rule.

I disabled this rule for the assertions in the tests via eslint-plugin-chai-friendly, and set it to error in the rest of the code. I also corrected the remaining errors.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #00000
  • There are new or updated tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Logic Error

The catch block now unconditionally throws an error even when the try block succeeds. The throw statement at line 992 should be inside the catch block, not after it. This will cause the driver to always fail initialization.

try {
    const oracle = this.options.driver || PlatformTools.load("oracledb")
    this.oracle = oracle
} catch {
    throw new DriverPackageNotInstalledError("Oracle", "oracledb")
}
Missing Logic

The thick mode initialization logic has been moved outside the conditional check. Lines 996-1000 will execute regardless of whether thickMode is truthy, potentially causing initialization when it shouldn't occur.

if (thickMode) {
    if (typeof thickMode === "object") {
        this.oracle.initOracleClient(thickMode)
    } else {
        this.oracle.initOracleClient()
    }
}
Redundant Check

The added null checks for msg at lines 1580 and 1585 are redundant since the original code already handled this with short-circuit evaluation. The event handlers are only called when messages exist, making these checks unnecessary.

    if (msg) {
        this.connection.logger.log("info", msg.message)
    }
})
connection.on("notification", (msg: any) => {
    if (msg) {
        this.connection.logger.log(
            "info",
            `Received NOTIFY on channel ${msg.channel}: ${msg.payload}.`,
        )
    }

@pkg-pr-new

pkg-pr-new Bot commented Dec 8, 2025

Copy link
Copy Markdown
  • typeorm-sql-js-example

    npm i https://pkg.pr.new/typeorm/typeorm@11833
    

commit: e47106b

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Use a stricter equality check

To make the test assertion more precise, replace .to.have.members() with
.to.deep.equal() to check for exact order and content.

test/functional/query-builder/distinct-on/query-builder-distinct-on.test.ts [139-148]

-expect(
-    result.map(({ moderator }) => moderator),
-).to.have.members(["Dion", "Sarah", "Dion", "Dion"])
+expect(result.map(({ moderator }) => moderator)).to.deep.equal([
+    "Dion",
+    "Sarah",
+    "Dion",
+    "Dion",
+])
 
 expect(result.map(({ author }) => author)).to.have.members([
     "Dion",
     "Pablo",
     "Sarah",
     "Zelda",
 ])
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies that deep.equal is a stricter assertion than have.members, but it's only a minor improvement as the current test is not incorrect and the order of results is not guaranteed by the query.

Low
  • More

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 80.764% (-0.007%) from 80.771%
when pulling e47106b on alumni:chore/chai-eslint-plugin
into cc07c90 on typeorm:master.

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👏 thanks for your commitment @alumni

@alumni
alumni merged commit 2133c97 into typeorm:master Dec 8, 2025
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
kranners pushed a commit to kranners/typeorm that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants