镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Replacement/improvement of func-name-matching eslint rule #57899

Description

@LiviaMedeiros

There are quite a few places where a property is defined like this:

ObjectDefineProperty(someObject, 'someFunction', {
  __proto__: null,
  value: function() {
    /* `someObject.someFunction`'s body */
  },
});

As result, we end up with quite a few functions named value:

someObject.someFunction.name === 'value'

There is a func-name-matching rule in eslint that enforces function names to match the property names. However, in these cases, this rule rejects correct code and insists that these functions must be named value, to the point that in some places we have them explicitly named like this:

value: function value() {

I think, it would be nice to have a custom linter rule that:

  • works the same way as func-name-matching everywhere outside of ObjectDefineProperty, ObjectDefineProperties, and ReflectDefineProperty
  • in the descriptors in these functions, the rule should be reversed: it should not allow the function to end up with a name value
  • (ideally) if property name(s) is defined as plain string, the function name must match this string

I'm not familiar with eslint rules definitions but the original func-name-matching rule seems to be defined here: https://github.com/eslint/eslint/blob/e8f8d57bd6c0d95f9f25db8c5b3ff72de42488b7/lib/rules/func-name-matching.js.

The rule already has considerPropertyDescriptor option, but it's not applicable here because:

  • it recognizes the normal form of these functions (Object.defineProperty) but not primordials (ObjectDefineProperty)
  • it still allows both implicitly inherited name (value: function() {) and concise notation (value() {)
  • it also disables the rule inside of Object.create()

Activity

  1. added
    toolsIssues and PRs related to the tools directory.
    on Apr 16, 2025
  2. github-actions commented on Apr 20, 2026

    @github-actions
  3. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Apr 20, 2026
  4. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on May 16, 2026
  5. louiellan commented on May 17, 2026

    @louiellan
    Contributor

    fwiw, i just found out that we can't really propose a change anymore with the func-name-matching rule on the eslint itself cause they made it a frozen rule

  6. github-actions commented on Sep 4, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  7. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Sep 4, 2026
  8. github-actions commented on Oct 4, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.toolsIssues and PRs related to the tools directory.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions