]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/docs/src/rules/prefer-reflect.md
import 8.41.0 source
[pve-eslint.git] / eslint / docs / src / rules / prefer-reflect.md
index ea2ee7d416d938ed5e491be0f08b87f2502f5261..e2a632eb6c66d6bdb6f32ad9650ff475bad06cf1 100644 (file)
@@ -1,6 +1,5 @@
 ---
 title: prefer-reflect
-layout: doc
 rule_type: suggestion
 related_rules:
 - no-useless-call
@@ -11,6 +10,8 @@ related_rules:
 
 This rule was **deprecated** in ESLint v3.9.0 and will not be replaced. The original intent of this rule now seems misguided as we have come to understand that `Reflect` methods are not actually intended to replace the `Object` counterparts the rule suggests, but rather exist as low-level primitives to be used with proxies in order to replicate the default behavior of various previously existing functionality.
 
+**Please note**: This rule contains an incorrect behavior - it will suggest you to use `Reflect.getOwnPropertyNames` rather than `Object.getOwnPropertyNames`, but the former one doesn't exist in the [specification](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-reflection). We suggest using the `exceptions` option with `"getOwnPropertyNames"` to avoid this false suggestion.
+
 The ES6 Reflect API comes with a handful of methods which somewhat deprecate methods on old constructors:
 
 * [`Reflect.apply`](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-reflect.apply) effectively deprecates [`Function.prototype.apply`](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-function.prototype.apply) and [`Function.prototype.call`](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-function.prototype.call)
@@ -320,47 +321,6 @@ Reflect.isExtensible({})
 
 :::
 
-### Reflect.getOwnPropertyNames
-
-Deprecates `Object.getOwnPropertyNames()`
-
-Examples of **incorrect** code for this rule when used without exceptions:
-
-::: incorrect
-
-```js
-/*eslint prefer-reflect: "error"*/
-
-Object.getOwnPropertyNames({})
-```
-
-:::
-
-Examples of **correct** code for this rule when used without exceptions:
-
-::: correct
-
-```js
-/*eslint prefer-reflect: "error"*/
-
-Reflect.getOwnPropertyNames({})
-```
-
-:::
-
-Examples of **correct** code for this rule with the `{ "exceptions": ["getOwnPropertyNames"] }` option:
-
-::: correct
-
-```js
-/*eslint prefer-reflect: ["error", { "exceptions": ["getOwnPropertyNames"] }]*/
-
-Object.getOwnPropertyNames({})
-Reflect.getOwnPropertyNames({})
-```
-
-:::
-
 ### Reflect.preventExtensions
 
 Deprecates `Object.preventExtensions()`