From df939e39ec292b9fd171cc05ec8b4154374cfc9a Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Mon, 2 Jul 2018 15:30:17 -0600 Subject: [PATCH] =?UTF-8?q?[Tests]=20`no-access-state-in-setstate`:=20pass?= =?UTF-8?q?ing=20test=20for=20=E2=80=9Cdon't=20error=20if=20it's=20not=20a?= =?UTF-8?q?=20React=20Component=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ tests/lib/rules/no-access-state-in-setstate.js | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 258495898a..1f67fd5098 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,12 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ### Fixed * [`display-name`]: Get rid of false position on component detection ([#2759] @iiison) +### Changed +* [`no-access-state-in-setstate`]: passing test for “don't error if it's not a React Component” ([#1873] @kentcdodds) + [#2640]: https://github.com/yannickcr/eslint-plugin-react/pull/2640 [#2759]: https://github.com/yannickcr/eslint-plugin-react/pull/2759 +[#1873]: https://github.com/yannickcr/eslint-plugin-react/pull/1873 ## [7.25.3] - 2021.09.19 diff --git a/tests/lib/rules/no-access-state-in-setstate.js b/tests/lib/rules/no-access-state-in-setstate.js index ff621ddb5c..90e538bafc 100644 --- a/tests/lib/rules/no-access-state-in-setstate.js +++ b/tests/lib/rules/no-access-state-in-setstate.js @@ -137,6 +137,15 @@ ruleTester.run('no-access-state-in-setstate', rule, { `, parser: parsers.BABEL_ESLINT, parserOptions + }, { + code: [ + 'class StateContainer extends Container {', + ' anything() {', + ' return this.setState({value: this.state.value + 1})', + ' }', + '};' + ].join('\n'), + parserOptions }], invalid: [{