Skip to content

Commit

Permalink
resolve previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
V2dha committed Aug 5, 2022
1 parent 0bf8373 commit 9b595b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-no-target-blank.js
Expand Up @@ -103,7 +103,7 @@ function hasSecureRel(node, allowReferrer, warnOnSpreadAttributes, spreadAttribu

const relAttribute = node.attributes[relIndex];
const value = getStringFromValue(relAttribute.value);
return [].concat(value).filter(Boolean).some((item) => {
return [].concat(value).filter(Boolean).every((item) => {
const tags = typeof item === 'string' && item.toLowerCase().split(' ');
const noreferrer = tags && tags.indexOf('noreferrer') >= 0;
const noopener = tags && tags.indexOf('noopener') >= 0;
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/jsx-no-target-blank.js
Expand Up @@ -390,5 +390,14 @@ ruleTester.run('jsx-no-target-blank', rule, {
code: '<a href={href} target="_blank" rel={isExternal ? 3 : "noopener noreferrer"} />',
errors: defaultErrors,
},
{
code: '<a href={href} target="_blank" rel={isExternal ? "noopener noreferrer" : "3"} />',
errors: defaultErrors,
},
{
code: '<a href={href} target="_blank" rel={isExternal ? "noopener" : "2"} />',
options: [{ allowReferrer: true }],
errors: allowReferrerErrors,
},
]),
});

0 comments on commit 9b595b9

Please sign in to comment.