Skip to content

Commit a1b8888

Browse files
committed
add test case
1 parent fce69eb commit a1b8888

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/lib/rules/no-unused-state.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,26 @@ eslintTester.run('no-unused-state', rule, {
10591059
errors: getErrorMessages(['foo']),
10601060
parser: parsers.BABEL_ESLINT
10611061
},
1062+
{
1063+
code: `class UseStateParameterOfNonLifecycleTest extends Component {
1064+
constructor(props) {
1065+
super(props);
1066+
this.state = {
1067+
foo: 123,
1068+
};
1069+
}
1070+
nonLifecycle(someProps, someState) {
1071+
doStuff(someState.foo)
1072+
}
1073+
render() {
1074+
return (
1075+
<SomeComponent />
1076+
);
1077+
}
1078+
}`,
1079+
errors: getErrorMessages(['foo']),
1080+
parser: parsers.BABEL_ESLINT
1081+
},
10621082
{
10631083
code: `class MissingStateParameterTest extends Component {
10641084
constructor(props) {

0 commit comments

Comments
 (0)