From 253a62aad32c1eadfd73b5078ffbde68269b7fad Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 28 Jul 2020 11:48:06 -0700 Subject: [PATCH] [Tests] `no-access-state-in-setstate`: add passing tests Closes #1931 --- tests/lib/rules/no-access-state-in-setstate.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/lib/rules/no-access-state-in-setstate.js b/tests/lib/rules/no-access-state-in-setstate.js index dfbf7530e3..9f8bf6ff97 100644 --- a/tests/lib/rules/no-access-state-in-setstate.js +++ b/tests/lib/rules/no-access-state-in-setstate.js @@ -11,6 +11,7 @@ const RuleTester = require('eslint').RuleTester; const rule = require('../../../lib/rules/no-access-state-in-setstate'); +const parsers = require('../../helpers/parsers'); const parserOptions = { ecmaVersion: 2018, @@ -102,6 +103,23 @@ ruleTester.run('no-access-state-in-setstate', rule, { }; `, parserOptions + }, { + code: ` + class ComponentA extends React.Component { + state = { + greeting: 'hello', + }; + + myFunc = () => { + this.setState({ greeting: 'hi' }, () => this.doStuff()); + }; + + doStuff = () => { + console.log(this.state.greeting); + }; + } + `, + parser: parsers.BABEL_ESLINT, }], invalid: [{