-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[jsx-no-bind] Only warn for props and account for variable declaration #1459
[jsx-no-bind] Only warn for props and account for variable declaration #1459
Conversation
…eact into make-jsx-no-bind-only-warn-for-props Conflicts: tests/lib/rules/jsx-no-bind.js
) { | ||
return; | ||
} | ||
const ancestors = context.getAncestors(callee).reverse(); |
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.
I think this block of code reports any violation in a component's render
method. This rule is supposed to only report violations in JSX props, so this is not needed.
' }', | ||
'};' | ||
].join('\n'), | ||
parser: 'babel-eslint' |
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.
most of these test cases don't need babel-eslint
; can we use the default parser wherever possible?
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.
What about async arrow functions?
@ljharb Forgot about them. Will fix. 😅 |
Thanks for the feedback! I have gotten rid of all the unnecessary Now I will always keep async arrow functions in mind for future contributions. let me know if there is anything else I can improve on this PR. 😄 |
@jackyho112 I was mainly asking about ensuring that |
@ljharb 😄 , didn't know. I'm on it! |
Let's also ensure that |
@ljharb Good call. Gonna have to do it tomorrow though. |
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.
Thanks, this LGTM
Thanks for the approval! |
@windhost can you file a separate issue for that? since |
@ljharb 👌 |
This will fix #1444, #1395 and #1417, so that the rule will only warn if there are violations in JSX attributes and will keep track of
const
variable declarations of violations.For examples,
will warn.
But
will not.
The new implementation is simply keeping track of each
const
variable declaration that references a violation in each block statement and reports them if they got passed into JSX props.With the update, this rule does not account for any assignment expression and variable declarations that are not
const
. I feel that it is acceptable to leave them for future updates.Please let me know if there is any idea for improvements. 😄
Fixes #1444. Fixes #1395. Fixes #1417.