-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
no-did-(update|mount)-set-state: disallow-via-methods
option
#742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
deb7fb5
to
c62b0f4
Compare
I'm not sure this needs to be a separate rule. It would also be nice if it allowed these function calls as callbacks with an option to disallow, like we do with the What do other folks think? |
c62b0f4
to
9fccdf9
Compare
disallow-via-methods
option
I've updated my PR to not create a separate rule for this use case. Instead it uses the logic in both |
👍 / 👎 ? Friendly bump! |
|
||
The following patterns are considered warnings: | ||
|
||
```js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these should be jsx
```js | ||
... | ||
"no-did-update-set-state": [<enabled>, <mode>] | ||
"no-did-update-set-state": [<enabled>, <modeInFunctions>, <modeViaMethods>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good idea to use an options object for these modes instead of positional arguments.
That would be a breaking change, so perhaps it should be done in a followup PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both could be supported with eslint schemas as semver-minor - ie, a "mode" string, and then otherwise, an options object.
Ah yes, that would be preferable
…On Wed, Feb 15, 2017, 11:54 AM Jordan Harband ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In docs/rules/no-did-update-set-state.md
<#742>:
> @@ -51,7 +51,7 @@ var Hello = React.createClass({
```js
...
-"no-did-update-set-state": [<enabled>, <mode>]
+"no-did-update-set-state": [<enabled>, <modeInFunctions>, <modeViaMethods>]
Both could be supported with eslint schemas as semver-minor - ie, a "mode"
string, and then otherwise, an options object.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#742>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAL7zgojwTRK-O-tXmnYP-YhdnJ4BeH8ks5rc1fcgaJpZM4JdpvP>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a rebase, and it'd be great to use an options object per https://github.com/yannickcr/eslint-plugin-react/pull/742/files#r101368104
I've rebased this, but a few tests are failing. |
59af733
to
865ed16
Compare
069314a
to
181c68f
Compare
380e32c
to
51d342b
Compare
[RFC] Adding a new rule to complement the existing
no-did-update-set-state
.This rule will look for any occurrences of
this.setState
and check whether the method it is being called from is also called insidecomponentDidUpdate
.If this gets a positive feedback I'll also add a doc page for it.
I could see this as an option on the
no-did-update-set-state
rule, but the logic is more complex than the original rule, so I decided to keep it separate for now.