From c569d87741d32efbc844c0469912cb6490f99061 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Fri, 16 Sep 2022 01:44:48 +0000 Subject: [PATCH 1/6] docs: Add note to disclose inappropriate behavior Due to https://github.com/eslint/eslint/issues/16305#issuecomment-1247935311 the falsely suggestion should be disclose to users to avoid further confusion See #16305 --- docs/src/rules/prefer-reflect.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/src/rules/prefer-reflect.md b/docs/src/rules/prefer-reflect.md index ea2ee7d416d..f1785ac5d1e 100644 --- a/docs/src/rules/prefer-reflect.md +++ b/docs/src/rules/prefer-reflect.md @@ -11,6 +11,10 @@ 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 inappropriate behavior - it will suggest you to use `Reflect.getOwnPropertyNames` rather than `Object.getOwnPropertyNames`, but the former doesn't exist in the [spec](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-reflection). We suggest using `exceptions` option with `getOwnPropertyNames` to avoid this falsely 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) From 4c7c615e3de3d1b1657f85f5c0539e793bff4bba Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Fri, 16 Sep 2022 01:59:51 +0000 Subject: [PATCH 2/6] docs(prefer-reflect): Remove the section about `getOwnPropertyNames` Make the document clean --- docs/src/rules/prefer-reflect.md | 44 ++------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/docs/src/rules/prefer-reflect.md b/docs/src/rules/prefer-reflect.md index f1785ac5d1e..7e88e373a04 100644 --- a/docs/src/rules/prefer-reflect.md +++ b/docs/src/rules/prefer-reflect.md @@ -8,10 +8,11 @@ related_rules: - no-delete-var --- +---- 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 inappropriate behavior - it will suggest you to use `Reflect.getOwnPropertyNames` rather than `Object.getOwnPropertyNames`, but the former doesn't exist in the [spec](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-reflection). We suggest using `exceptions` option with `getOwnPropertyNames` to avoid this falsely suggestion. +**Please note**: This rule contains an inappropriate behavior - it will suggest you to use `Reflect.getOwnPropertyNames` rather than `Object.getOwnPropertyNames`, but the former one doesn't exist in the [spec](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-reflection). We suggest using `exceptions` option with `getOwnPropertyNames` to avoid this falsely suggestion. ---- @@ -324,47 +325,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()` From 019fe71b27bab81f89de2a9aed3e237f99f82b4e Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Fri, 16 Sep 2022 20:21:43 +0800 Subject: [PATCH 3/6] docs: Apply suggestions from code review Co-authored-by: Milos Djermanovic --- docs/src/rules/prefer-reflect.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/src/rules/prefer-reflect.md b/docs/src/rules/prefer-reflect.md index 7e88e373a04..4d0f049df84 100644 --- a/docs/src/rules/prefer-reflect.md +++ b/docs/src/rules/prefer-reflect.md @@ -8,13 +8,11 @@ related_rules: - no-delete-var --- ----- 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 inappropriate behavior - it will suggest you to use `Reflect.getOwnPropertyNames` rather than `Object.getOwnPropertyNames`, but the former one doesn't exist in the [spec](https://www.ecma-international.org/ecma-262/6.0/index.html#sec-reflection). We suggest using `exceptions` option with `getOwnPropertyNames` to avoid this falsely suggestion. +**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 `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: From 016eab8f6119550b45a60aded38fa32242896dc0 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Mon, 19 Sep 2022 09:43:55 +0800 Subject: [PATCH 4/6] docs: Mark the value as string Co-authored-by: Milos Djermanovic --- docs/src/rules/prefer-reflect.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/rules/prefer-reflect.md b/docs/src/rules/prefer-reflect.md index 4d0f049df84..dd02c382d77 100644 --- a/docs/src/rules/prefer-reflect.md +++ b/docs/src/rules/prefer-reflect.md @@ -11,7 +11,7 @@ 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 `exceptions` option with `getOwnPropertyNames` to avoid this false suggestion. +**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: From e94a07a436e29a9865284ea488671a1023a705cf Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Mon, 19 Sep 2022 19:34:52 +0800 Subject: [PATCH 5/6] docs: remove duplicated consecutive blank line Co-authored-by: Milos Djermanovic --- docs/src/rules/prefer-reflect.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/src/rules/prefer-reflect.md b/docs/src/rules/prefer-reflect.md index dd02c382d77..1ae3573d33f 100644 --- a/docs/src/rules/prefer-reflect.md +++ b/docs/src/rules/prefer-reflect.md @@ -12,8 +12,6 @@ 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) From e2dead97a67efeefeb78ff1c62f55acb9d3f5e44 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Mon, 19 Sep 2022 20:46:26 +0200 Subject: [PATCH 6/6] Update docs/src/rules/prefer-reflect.md --- docs/src/rules/prefer-reflect.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/rules/prefer-reflect.md b/docs/src/rules/prefer-reflect.md index 1ae3573d33f..fa61d64101b 100644 --- a/docs/src/rules/prefer-reflect.md +++ b/docs/src/rules/prefer-reflect.md @@ -12,6 +12,7 @@ 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)