@@ -265,7 +265,30 @@ ruleTester.run("computed-property-spacing", rule, {
265265] . join ( "\n" ) ,
266266options :[ "never" ] ,
267267parserOptions :{ ecmaVersion :6 }
268+ } ,
269+
270+ // Destructuring Assignment
271+ {
272+ code :"const { [a]: someProp } = obj;" ,
273+ options :[ "never" ] ,
274+ parserOptions :{ ecmaVersion :6 }
275+ } ,
276+ {
277+ code :"({ [a]: someProp } = obj);" ,
278+ options :[ "never" ] ,
279+ parserOptions :{ ecmaVersion :6 }
280+ } ,
281+ {
282+ code :"const { [ a ]: someProp } = obj;" ,
283+ options :[ "always" ] ,
284+ parserOptions :{ ecmaVersion :6 }
285+ } ,
286+ {
287+ code :"({ [ a ]: someProp } = obj);" ,
288+ options :[ "always" ] ,
289+ parserOptions :{ ecmaVersion :6 }
268290}
291+
269292] ,
270293
271294invalid :[
@@ -2062,6 +2085,66 @@ ruleTester.run("computed-property-spacing", rule, {
20622085{ messageId :"unexpectedSpaceAfter" , data :{ tokenValue :"[" } } ,
20632086{ messageId :"unexpectedSpaceBefore" , data :{ tokenValue :"]" } }
20642087]
2088+ } ,
2089+
2090+ // Destructuring Assignment
2091+ {
2092+ code :"const { [ a]: someProp } = obj;" ,
2093+ output :"const { [a]: someProp } = obj;" ,
2094+ options :[ "never" ] ,
2095+ parserOptions :{ ecmaVersion :2022 } ,
2096+ errors :[
2097+ { messageId :"unexpectedSpaceAfter" , data :{ tokenValue :"[" } }
2098+ ]
2099+ } ,
2100+ {
2101+ code :"const { [a ]: someProp } = obj;" ,
2102+ output :"const { [a]: someProp } = obj;" ,
2103+ options :[ "never" ] ,
2104+ parserOptions :{ ecmaVersion :2022 } ,
2105+ errors :[
2106+ { messageId :"unexpectedSpaceBefore" , data :{ tokenValue :"]" } }
2107+ ]
2108+ } ,
2109+ {
2110+ code :"const { [ a ]: someProp } = obj;" ,
2111+ output :"const { [a]: someProp } = obj;" ,
2112+ options :[ "never" ] ,
2113+ parserOptions :{ ecmaVersion :2022 } ,
2114+ errors :[
2115+ { messageId :"unexpectedSpaceAfter" , data :{ tokenValue :"[" } } ,
2116+ { messageId :"unexpectedSpaceBefore" , data :{ tokenValue :"]" } }
2117+ ]
2118+ } ,
2119+ {
2120+ code :"({ [ a ]: someProp } = obj);" ,
2121+ output :"({ [a]: someProp } = obj);" ,
2122+ options :[ "never" ] ,
2123+ parserOptions :{ ecmaVersion :2022 } ,
2124+ errors :[
2125+ { messageId :"unexpectedSpaceAfter" , data :{ tokenValue :"[" } } ,
2126+ { messageId :"unexpectedSpaceBefore" , data :{ tokenValue :"]" } }
2127+ ]
2128+ } ,
2129+ {
2130+ code :"const { [a]: someProp } = obj;" ,
2131+ output :"const { [ a ]: someProp } = obj;" ,
2132+ options :[ "always" ] ,
2133+ parserOptions :{ ecmaVersion :2022 } ,
2134+ errors :[
2135+ { messageId :"missingSpaceAfter" , data :{ tokenValue :"[" } } ,
2136+ { messageId :"missingSpaceBefore" , data :{ tokenValue :"]" } }
2137+ ]
2138+ } ,
2139+ {
2140+ code :"({ [a]: someProp } = obj);" ,
2141+ output :"({ [ a ]: someProp } = obj);" ,
2142+ options :[ "always" ] ,
2143+ parserOptions :{ ecmaVersion :2022 } ,
2144+ errors :[
2145+ { messageId :"missingSpaceAfter" , data :{ tokenValue :"[" } } ,
2146+ { messageId :"missingSpaceBefore" , data :{ tokenValue :"]" } }
2147+ ]
20652148}
20662149]
20672150} ) ;