Bug: The `Reflect.getOwnPropertyNames` still doesn't exist
See original GitHub issueEnvironment
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.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Docs: Reflect.getOwnPropertyNames does not exist · Issue #7075 ...
In the documentation and source code for the prefer-reflect rule, the user is instructed to use Reflect. ... getOwnPropertyNames doesn't actually exist.
Read more >Object.getOwnPropertyNames() - JavaScript - MDN Web Docs
The Object.getOwnPropertyNames() method returns an array of all properties (including non-enumerable properties except for those which use Symbol) found ...
Read more >Metaprogramming in ES6: Part 2 - Reflect - Keith Cirkel
Symbols are all about Reflection within implementation - you sprinkle them on your existing classes and objects to change the behaviour.
Read more >Proxy and Reflect - The Modern JavaScript Tutorial
Proxy is a special “exotic object”. It doesn't have own properties. With an empty handler it transparently forwards operations to target . To ......
Read more >How did I leverage Proxies to make JavaScript errors pleasant ...
keys or Object.getOwnPropertyNames to obtain the list of all available own keys, yet still, no dice, the result was not quite something you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That would work, but this rule wasn’t intended to suggest replacements of such complexity, so I think it’s fine to add a note in the docs that
Object.getOwnPropertyNames
was added by mistake.@mdjermanovic OK, I will make a PR to change the documents only.