diff --git a/lib/rules/template-link-href-attributes.js b/lib/rules/template-link-href-attributes.js index d42d111452..3f7c99d49b 100644 --- a/lib/rules/template-link-href-attributes.js +++ b/lib/rules/template-link-href-attributes.js @@ -27,6 +27,13 @@ module.exports = { const hasHref = node.attributes?.some((attr) => attr.name === 'href'); if (!hasHref) { + // Exception: with both role and aria-disabled doesn't need href + const hasRole = node.attributes?.some((attr) => attr.name === 'role'); + const hasAriaDisabled = node.attributes?.some((attr) => attr.name === 'aria-disabled'); + if (hasRole && hasAriaDisabled) { + return; + } + context.report({ node, messageId: 'missingHref', diff --git a/tests/lib/rules/template-link-href-attributes.js b/tests/lib/rules/template-link-href-attributes.js index 3a064302b7..4532999508 100644 --- a/tests/lib/rules/template-link-href-attributes.js +++ b/tests/lib/rules/template-link-href-attributes.js @@ -11,6 +11,11 @@ ruleTester.run('template-link-href-attributes', rule, { '', '', '', + '', + '', + '', + '', + '', ], invalid: [ @@ -29,5 +34,10 @@ ruleTester.run('template-link-href-attributes', rule, { output: null, errors: [{ messageId: 'missingHref' }], }, + { + code: '', + output: null, + errors: [{ messageId: 'missingHref' }], + }, ], });