diff --git a/lib/rules/a11y-no-generic-link-text.js b/lib/rules/a11y-no-generic-link-text.js index 14bc41bd..a262b43e 100644 --- a/lib/rules/a11y-no-generic-link-text.js +++ b/lib/rules/a11y-no-generic-link-text.js @@ -29,7 +29,9 @@ module.exports = { let cleanTextContent // text content we can reliably fetch const parent = node.parent + let jsxTextNode if (parent.children && parent.children.length > 0 && parent.children[0].type === 'JSXText') { + jsxTextNode = parent.children[0] cleanTextContent = stripAndDowncaseText(parent.children[0].value) } @@ -54,7 +56,7 @@ module.exports = { if (cleanTextContent) { if (!bannedLinkText.includes(cleanTextContent)) return context.report({ - node, + node: jsxTextNode, message: 'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.' })