Description
Right now the jsx-no-target-blank rule only fires if the href is a literal string. What about the cases when the value of the href comes from a JSX expression? For example:
<a target='_blank' href={this.props.url}></a>
This might be even more dangerous if the URL property is provided by the user or the third-party.
Would it make sense to add a function hasDynamicLink() like this one:
function hasDynamicLink(element) {
return element.attributes.some(attr => attr.name &&
attr.name.name === 'href' &&
attr.value.type === 'JSXExpressionContainer');
}
And then include it in the condition for the rule:
if (
isTargetBlank(node) &&
(hasExternalLink(node.parent) || hasDynamicLink(node.parent)) &&
!hasSecureRel(node.parent)
)
I tested it out locally. Will be happy to help with a PR.