Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[unbound-method] False positive onIntl.Collator.compare #4383

Closed
Labels
package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginstalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged periodunable to reproissues that a maintainer was not able to reproduce
@kestrelnova

Description

@kestrelnova
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I haveread the FAQ and my problem is not listed.

Repro

{"rules": {"@typescript-eslint/unbound-method":"error"  }}
constcollator=newIntl.Collator("en")constsorted=["foo","bar"].sort(collator.compare)

(tsconfig not included as the same issue occurs regardless of config)

Expected Result

No error, asIntl.Collator.compare is a native bound method intended to be used this way.

Actual Result

2:36  error  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  @typescript-eslint/unbound-method

Additional Info

The rule's source code does account for builtins, but it looks like only top-level bound methods are put on the list to ignore when checking. SoIntl.Collator itself is ignored, butIntl.Collator.compare isn't because it's another level down. Presumably the same issue affects other similar methods likeIntl.DateFormat.format as well -- maybe check theIntl constructors individually when generating the ignore list?

Versions

packageversion
@typescript-eslint/eslint-plugin5.8.1
@typescript-eslint/parser5.8.1
TypeScript4.5.4
ESLint8.6.0
node17.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginstalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged periodunable to reproissues that a maintainer was not able to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp