@@ -27,34 +27,74 @@ ruleTester.run("no-useless-computed-key", rule, {
2727 invalid : [
2828 {
2929 code : "({ ['0']: 0 })" ,
30+ output : "({ '0': 0 })" ,
3031 env : { es6 : true } ,
3132 errors : [ {
3233 message : "Unnecessarily computed property ['0'] found." , type : "Property"
3334 } ]
3435 } , {
3536 code : "({ ['0+1,234']: 0 })" ,
37+ output : "({ '0+1,234': 0 })" ,
3638 env : { es6 : true } ,
3739 errors : [ {
3840 message : "Unnecessarily computed property ['0+1,234'] found." , type : "Property"
3941 } ]
4042 } , {
4143 code : "({ [0]: 0 })" ,
44+ output : "({ 0: 0 })" ,
4245 env : { es6 : true } ,
4346 errors : [ {
4447 message : "Unnecessarily computed property [0] found." , type : "Property"
4548 } ]
4649 } , {
4750 code : "({ ['x']: 0 })" ,
51+ output : "({ 'x': 0 })" ,
4852 env : { es6 : true } ,
4953 errors : [ {
5054 message : "Unnecessarily computed property ['x'] found." , type : "Property"
5155 } ]
5256 } , {
5357 code : "({ ['x']() {} })" ,
58+ output : "({ 'x'() {} })" ,
5459 env : { es6 : true } ,
5560 errors : [ {
5661 message : "Unnecessarily computed property ['x'] found." , type : "Property"
5762 } ]
63+ } , {
64+ code : "({ [/* this comment prevents a fix */ 'x']: 0 })" ,
65+ output : "({ [/* this comment prevents a fix */ 'x']: 0 })" ,
66+ env : { es6 : true } ,
67+ errors : [ {
68+ message : "Unnecessarily computed property ['x'] found." , type : "Property"
69+ } ]
70+ } , {
71+ code : "({ ['x' /* this comment also prevents a fix */]: 0 })" ,
72+ output : "({ ['x' /* this comment also prevents a fix */]: 0 })" ,
73+ env : { es6 : true } ,
74+ errors : [ {
75+ message : "Unnecessarily computed property ['x'] found." , type : "Property"
76+ } ]
77+ } , {
78+ code : "({ [('x')]: 0 })" ,
79+ output : "({ 'x': 0 })" ,
80+ env : { es6 : true } ,
81+ errors : [ {
82+ message : "Unnecessarily computed property ['x'] found." , type : "Property"
83+ } ]
84+ } , {
85+ code : "({ *['x']() {} })" ,
86+ output : "({ *'x'() {} })" ,
87+ env : { es6 : true } ,
88+ errors : [ {
89+ message : "Unnecessarily computed property ['x'] found." , type : "Property"
90+ } ]
91+ } , {
92+ code : "({ async ['x']() {} })" ,
93+ output : "({ async 'x'() {} })" ,
94+ parserOptions : { ecmaVersion : 8 } ,
95+ errors : [ {
96+ message : "Unnecessarily computed property ['x'] found." , type : "Property"
97+ } ]
5898 }
5999 ]
60100} ) ;
0 commit comments