From 66570cc2c630a5336725f8af987b62b93361da5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Thu, 12 Mar 2026 23:16:11 +0100 Subject: [PATCH] Fix template-link-href-attributes: add role+aria-disabled exception Add missing exception from original: with both role and aria-disabled should not require href. Also add test cases for edge cases. --- lib/rules/template-link-href-attributes.js | 7 +++++++ tests/lib/rules/template-link-href-attributes.js | 10 ++++++++++ 2 files changed, 17 insertions(+) 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' }], + }, ], });