Skip to content

Commit df939e3

Browse files
Kent C. Doddsljharb
Kent C. Dodds
authored andcommitted
[Tests] no-access-state-in-setstate: passing test for “don't error if it's not a React Component”
1 parent f4d4314 commit df939e3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1111
### Fixed
1212
* [`display-name`]: Get rid of false position on component detection ([#2759] @iiison)
1313

14+
### Changed
15+
* [`no-access-state-in-setstate`]: passing test for “don't error if it's not a React Component” ([#1873] @kentcdodds)
16+
1417
[#2640]: https://github.com/yannickcr/eslint-plugin-react/pull/2640
1518
[#2759]: https://github.com/yannickcr/eslint-plugin-react/pull/2759
19+
[#1873]: https://github.com/yannickcr/eslint-plugin-react/pull/1873
1620

1721
## [7.25.3] - 2021.09.19
1822

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

+9
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ ruleTester.run('no-access-state-in-setstate', rule, {
137137
`,
138138
parser: parsers.BABEL_ESLINT,
139139
parserOptions
140+
}, {
141+
code: [
142+
'class StateContainer extends Container {',
143+
' anything() {',
144+
' return this.setState({value: this.state.value + 1})',
145+
' }',
146+
'};'
147+
].join('\n'),
148+
parserOptions
140149
}],
141150

142151
invalid: [{

0 commit comments

Comments
 (0)