diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js index 551d640c20..a1a7deac5b 100644 --- a/lib/rules/jsx-no-target-blank.js +++ b/lib/rules/jsx-no-target-blank.js @@ -15,7 +15,7 @@ function isTargetBlank(attr) { } function hasExternalLink(element) { - return element.attributes.find(function (attr) { + return element.attributes.some(function (attr) { return attr.name && attr.name.name === 'href' && attr.value.type === 'Literal' && @@ -25,7 +25,7 @@ function hasExternalLink(element) { function hasSecureRel(element) { return element.attributes.find(function (attr) { - if (attr.name.name === 'rel') { + if (attr.type === 'JSXAttribute' && attr.name.name === 'rel') { const tags = attr.value && attr.value.type === 'Literal' && attr.value.value.toLowerCase().split(' '); return tags && (tags.indexOf('noopener') >= 0 && tags.indexOf('noreferrer') >= 0); } diff --git a/tests/lib/rules/jsx-no-target-blank.js b/tests/lib/rules/jsx-no-target-blank.js index ecd2c6d693..a0c756cbcc 100644 --- a/tests/lib/rules/jsx-no-target-blank.js +++ b/tests/lib/rules/jsx-no-target-blank.js @@ -31,6 +31,7 @@ ruleTester.run('jsx-no-target-blank', rule, { {code: ''}, {code: ''}, {code: ''}, + {code: 's'}, {code: ''}, {code: '

'}, {code: ''},