Skip to content

Bug: The Reflect.getOwnPropertyNames still doesn't exist #16305

@AnnAngela

Description

@AnnAngela

Environment

Node version: v16.17.0
npm version: v8.18.0
Local ESLint version: v8.23.0 (Currently used)
Global ESLint version: v8.23.0
Operating System: linux 5.4.0-1089-azure

What parser are you using?

Default (Espree)

What did you do?

Configuration
{
    "env": {
        "browser": true,
        "jquery": true,
        "es6": true,
        "es2020": true,
        "es2021": true
    },
    "parserOptions": {
        "ecmaVersion": "latest"
    },
    "extends": "eslint:recommended",
    "rules": {
        "prefer-reflect": "error"
    }
}

Code:

        function getOwnPropertyNamesLength(obj) {
            return Object.getOwnPropertyNames(obj).length;
        }

What did you expect to happen?

Due to the function Reflect.getOwnPropertyNames still doesn't exist (I can't even find it in caniuse.com), the rule prefer-reflect should not consider about it, so does the document.

What actually happened?

The rule complain that "Avoid using Object.getOwnPropertyNames, instead use Reflect.getOwnPropertyNames."

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

I knew that #7075 is about it and closed, but I met the problem again, that's why I submit this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyrepro:neededThis issue should include a reproducible example

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions