-
-
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
Handle spread props in jsx-no-target-blank rule #679
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,8 @@ ruleTester.run('jsx-no-target-blank', rule, { | |
valid: [ | ||
{code: '<a href="foobar"></a>', parserOptions: parserOptions}, | ||
{code: '<a randomTag></a>', parserOptions: parserOptions}, | ||
{code: '<a href="foobar" target="_blank" rel="noopener noreferrer"></a>', parserOptions: parserOptions} | ||
{code: '<a href="foobar" target="_blank" rel="noopener noreferrer"></a>', parserOptions: parserOptions}, | ||
{code: '<a target="_blank" {...spreadProps} rel="noopener noreferrer"></a>', parserOptions: parserOptions} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the ordering of "rel" and the spread props seems to matter, should we also have a test for one where "rel" appears first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It only matters because we break out of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's important to add, to prevent a regression - if there's already order-dependent bugs, there could easily be more added later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good thought. Added in 3db97e4. |
||
], | ||
invalid: [ | ||
{code: '<a target="_blank"></a>', parserOptions: parserOptions, | ||
|
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.
@yannickcr is there any reason this uses
for..in
instead ofObject.keys(…).forEach(…)
?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.
@ljharb If I remember correctly
Object.keys
is only supported since Node.js 4.0There 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.
@yannickcr
Object.keys
is ES5, and is supported since node 0.6.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.
@ljharb Ho ok, my bad. No reason to not using it then.
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.
Do you want this as part of this PR, or should it be a separate one? Feels unrelated to the bug IMO, but I'm willing to do it if you want.
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'm fine with separate, but either way :-)
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 looked at this today. There is a
break
inside thefor
loop which doesn't work in theforEach
version. I'm sure there's a way around that, but I think this should be in a separate PR. I'd like to have this one considered done and merged (if acceptable).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.
Yeah that'd require
.some
or similar. Separate PR is fine.