Skip to content

Commit c10ca73

Browse files
author
Kent C. Dodds
authored
don't error if it's not a React Component
unstated uses `this.setState` and we're getting false positives when using this rule.
1 parent 809a25d commit c10ca73

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,14 @@ ruleTester.run('no-access-state-in-setstate', rule, {
207207
errors: [{
208208
message: 'Use callback in setState when referencing the previous state.'
209209
}]
210+
}, {
211+
code: [
212+
'class StateContainer extends Container {',
213+
' anything() {',
214+
' return this.setState({value: this.state.value + 1})',
215+
' }',
216+
'};'
217+
].join('\n'),
218+
parserOptions: parserOptions
210219
}]
211220
});

0 commit comments

Comments
 (0)