Skip to content

Commit 253a62a

Browse files
committed
[Tests] no-access-state-in-setstate: add passing tests
Closes #1931
1 parent f0ff971 commit 253a62a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/lib/rules/no-access-state-in-setstate.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
const RuleTester = require('eslint').RuleTester;
1313
const rule = require('../../../lib/rules/no-access-state-in-setstate');
14+
const parsers = require('../../helpers/parsers');
1415

1516
const parserOptions = {
1617
ecmaVersion: 2018,
@@ -102,6 +103,23 @@ ruleTester.run('no-access-state-in-setstate', rule, {
102103
};
103104
`,
104105
parserOptions
106+
}, {
107+
code: `
108+
class ComponentA extends React.Component {
109+
state = {
110+
greeting: 'hello',
111+
};
112+
113+
myFunc = () => {
114+
this.setState({ greeting: 'hi' }, () => this.doStuff());
115+
};
116+
117+
doStuff = () => {
118+
console.log(this.state.greeting);
119+
};
120+
}
121+
`,
122+
parser: parsers.BABEL_ESLINT,
105123
}],
106124

107125
invalid: [{

0 commit comments

Comments
 (0)