@@ -62,6 +62,14 @@ eslintTester.run('no-unused-state', rule, {
62
62
return <SomeComponent foo={this.state[true]} />;
63
63
}
64
64
});` ,
65
+ `var ComputedKeyFromNumberLiteralTest = createReactClass({
66
+ getInitialState: function() {
67
+ return { [123]: 0 };
68
+ },
69
+ render: function() {
70
+ return <SomeComponent foo={this.state[123]} />;
71
+ }
72
+ });` ,
65
73
`var ComputedKeyFromExpressionTest = createReactClass({
66
74
getInitialState: function() {
67
75
return { [foo + bar]: 0 };
@@ -150,6 +158,14 @@ eslintTester.run('no-unused-state', rule, {
150
158
return <SomeComponent foo={this.state['false']} />;
151
159
}
152
160
}` ,
161
+ `class ComputedKeyFromNumberLiteralTest extends React.Component {
162
+ constructor() {
163
+ this.state = { [345]: 0 };
164
+ }
165
+ render() {
166
+ return <SomeComponent foo={this.state[345]} />;
167
+ }
168
+ }` ,
153
169
`class ComputedKeyFromExpressionTest extends React.Component {
154
170
constructor() {
155
171
this.state = { [foo + bar]: 0 };
@@ -465,6 +481,26 @@ eslintTester.run('no-unused-state', rule, {
465
481
errors : getErrorMessages ( [ 'true' ] ) ,
466
482
parser : 'babel-eslint'
467
483
} ,
484
+ {
485
+ code : `class UnusedComputedNumberLiteralKeyStateTest extends React.Component {
486
+ state = { [123]: 0 };
487
+ render() {
488
+ return <SomeComponent />;
489
+ }
490
+ }` ,
491
+ errors : getErrorMessages ( [ '123' ] ) ,
492
+ parser : 'babel-eslint'
493
+ } ,
494
+ {
495
+ code : `class UnusedComputedFloatLiteralKeyStateTest extends React.Component {
496
+ state = { [123.12]: 0 };
497
+ render() {
498
+ return <SomeComponent />;
499
+ }
500
+ }` ,
501
+ errors : getErrorMessages ( [ '123.12' ] ) ,
502
+ parser : 'babel-eslint'
503
+ } ,
468
504
{
469
505
code : `class UnusedStateWhenPropsAreSpreadTest extends React.Component {
470
506
constructor() {
0 commit comments