We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Add the following test to the valid section of test/lib/rules/jsx-no-target-blank.js {code: '<a href target="_blank"/>'},
{code: '<a href target="_blank"/>'},
The following error occurs TypeError: Cannot read property 'type' of null
Add attr.value && before attr.value.type === 'Literal'
attr.value &&
attr.value.type === 'Literal'
here is the updated function function hasExternalLink(node, linkAttribute, warnOnSpreadAttributes, spreadAttributeIndex) { const linkIndex = findLastIndex(node.attributes, (attr) => attr.name && attr.name.name === linkAttribute); const foundExternalLink = linkIndex !== -1 && ((attr) => attr.value && attr.value.type === 'Literal' && /^(?:\w+:|\/\/)/.test(attr.value.value))( node.attributes[linkIndex]); return foundExternalLink || (warnOnSpreadAttributes && linkIndex < spreadAttributeIndex); }
function hasExternalLink(node, linkAttribute, warnOnSpreadAttributes, spreadAttributeIndex) { const linkIndex = findLastIndex(node.attributes, (attr) => attr.name && attr.name.name === linkAttribute); const foundExternalLink = linkIndex !== -1 && ((attr) => attr.value && attr.value.type === 'Literal' && /^(?:\w+:|\/\/)/.test(attr.value.value))( node.attributes[linkIndex]); return foundExternalLink || (warnOnSpreadAttributes && linkIndex < spreadAttributeIndex); }
The text was updated successfully, but these errors were encountered:
Thanks!
Sorry, something went wrong.
952a768
my pleasure
No branches or pull requests
Scenario
Add the following test to the valid section of test/lib/rules/jsx-no-target-blank.js
{code: '<a href target="_blank"/>'},
Symptoms
The following error occurs
TypeError: Cannot read property 'type' of null
Resolution
Add
attr.value &&
beforeattr.value.type === 'Literal'
here is the updated function
function hasExternalLink(node, linkAttribute, warnOnSpreadAttributes, spreadAttributeIndex) { const linkIndex = findLastIndex(node.attributes, (attr) => attr.name && attr.name.name === linkAttribute); const foundExternalLink = linkIndex !== -1 && ((attr) => attr.value && attr.value.type === 'Literal' && /^(?:\w+:|\/\/)/.test(attr.value.value))( node.attributes[linkIndex]); return foundExternalLink || (warnOnSpreadAttributes && linkIndex < spreadAttributeIndex); }
The text was updated successfully, but these errors were encountered: