Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

### Fixed
* [`jsx-max-depth`]: Prevent getting stuck in circular references ([#2957][] @AriPerkkio)
* [`jsx-no-target-blank`]: fix handling of `warnOnSpreadAttributes` being false ([#2953][] @Nokel81)

### Changed
* Fix CHANGELOG.md ([#2950][] @JounQin)

[#2953]: https://github.com/yannickcr/eslint-plugin-react/pull/2953
[#2957]: https://github.com/yannickcr/eslint-plugin-react/pull/2957
[#2950]: https://github.com/yannickcr/eslint-plugin-react/pull/2950

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-no-target-blank.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ module.exports = {

if (warnOnSpreadAttributes && hasSpread) {
// continue to check below
} else if ((hasSpread && targetIndex < spreadAttributeIndex) || !hasSpread) {
} else if ((hasSpread && targetIndex < spreadAttributeIndex) || !hasSpread || !warnOnSpreadAttributes) {
return;
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/lib/rules/jsx-no-target-blank.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ ruleTester.run('jsx-no-target-blank', rule, {
},
{
code: '<a target={3} />'
},
{
code: '<a href="some-link" {...otherProps} target="some-non-blank-target"></a>'
},
{
code: '<a href="some-link" target="some-non-blank-target" {...otherProps}></a>'
}
],
invalid: [
Expand Down Expand Up @@ -266,6 +272,20 @@ ruleTester.run('jsx-no-target-blank', rule, {
options: [{enforceDynamicLinks: 'always'}],
settings: {linkComponents: {name: 'Link', linkAttribute: 'to'}},
errors: defaultErrors
},
{
code: '<a href="some-link" {...otherProps} target="some-non-blank-target"></a>',
errors: defaultErrors,
options: [{
warnOnSpreadAttributes: true
}]
},
{
code: '<a href="some-link" target="some-non-blank-target" {...otherProps}></a>',
errors: defaultErrors,
options: [{
warnOnSpreadAttributes: true
}]
}
]
});