From b7ca0c913cc5d3ee0e78e2657691f1c1fb4955f6 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 14 Dec 2021 07:31:43 +0530 Subject: [PATCH 1/2] docs: add destructuring examples for `computed-property-spacing` --- docs/rules/computed-property-spacing.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/rules/computed-property-spacing.md b/docs/rules/computed-property-spacing.md index 3fdd70ce001..935a1fb8462 100644 --- a/docs/rules/computed-property-spacing.md +++ b/docs/rules/computed-property-spacing.md @@ -48,6 +48,10 @@ obj[foo ] obj[ 'foo'] var x = {[ b ]: a} obj[foo[ bar ]] + +// applies to the spacing for dynamic keys (computed property key) when destructuring objects. +const { [ a ]: someProp } = obj; +({ [ b ]: anotherProp } = anotherObj); ``` Examples of **correct** code for this rule with the default `"never"` option: @@ -60,6 +64,10 @@ obj[foo] obj['foo'] var x = {[b]: a} obj[foo[bar]] + +// applies to the spacing for dynamic keys (computed property key) when destructuring objects. +const { [a]: someProp } = obj; +({ [b]: anotherProp } = anotherObj); ``` ### always @@ -76,6 +84,8 @@ obj[ foo] obj['foo' ] obj[foo[ bar ]] var x = {[ b]: a} +const { [a]: someProp } = obj; +({ [b ]: anotherProp } = anotherObj); ``` Examples of **correct** code for this rule with the `"always"` option: @@ -88,6 +98,8 @@ obj[ foo ] obj[ 'foo' ] var x = {[ b ]: a} obj[ foo[ bar ] ] +const { [ a ]: someProp } = obj; +({ [ b ]: anotherProp } = anotherObj); ``` #### enforceForClassMembers From 5668553b32676167e2326e6b39fddab39283e351 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 14 Dec 2021 22:55:17 +0530 Subject: [PATCH 2/2] docs: suggestions from code review Co-authored-by: Milos Djermanovic --- docs/rules/computed-property-spacing.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/rules/computed-property-spacing.md b/docs/rules/computed-property-spacing.md index 935a1fb8462..903642391b0 100644 --- a/docs/rules/computed-property-spacing.md +++ b/docs/rules/computed-property-spacing.md @@ -49,7 +49,6 @@ obj[ 'foo'] var x = {[ b ]: a} obj[foo[ bar ]] -// applies to the spacing for dynamic keys (computed property key) when destructuring objects. const { [ a ]: someProp } = obj; ({ [ b ]: anotherProp } = anotherObj); ``` @@ -65,7 +64,6 @@ obj['foo'] var x = {[b]: a} obj[foo[bar]] -// applies to the spacing for dynamic keys (computed property key) when destructuring objects. const { [a]: someProp } = obj; ({ [b]: anotherProp } = anotherObj); ```