Skip to content

[unbound-method] False positive on Intl.Collator.compare (reopen #4383) #7098

@jcranendonk

Description

@jcranendonk

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue (see description)
  • I have read the FAQ and my problem is not listed.

Playground Link

Minimal example

Repro Code

const collator = new Intl.Collator("en")
const sorted = ["foo", "bar"].sort(collator.compare)

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/unbound-method": "error"
  },
};

tsconfig

No response

Expected Result

The rule should not fire an error for this code, as Intl.Collator.prototype.compare is bound to collator according to the ECMAScript spec.

Actual Result

The rule fires for the use of collator.compare:

Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead. 4:36 - 4:52

Additional Info

This is a duplicate of #4383, which was marked 'unable to repro'. However, the playground example linked in the team response actually reproduces the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy