Skip to content

Commit 43eeb95

Browse files
committed
fix: make sure that title cannot be passed alongside the aria-label
1 parent a1b3f23 commit 43eeb95

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

__tests__/src/rules/anchor-has-content-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ ruleTester.run('anchor-has-content', rule, {
3838
settings: { 'jsx-a11y': { components: { Link: 'a' } } },
3939
},
4040
{ code: '<a aria-label={ariaLabel} />' },
41-
{ code: '<a title={title} aria-label={ariaLabel} />' },
4241
)).map(parserOptionsMapper),
4342
invalid: parsers.all([].concat(
4443
{ code: '<a />', errors: [expectedError] },
4544
{ code: '<a><Bar aria-hidden /></a>', errors: [expectedError] },
4645
{ code: '<a>{undefined}</a>', errors: [expectedError] },
4746
{ code: '<a title={title} />', errors: [expectedError] },
47+
{ code: '<a title={title} aria-label={ariaLabel} />', errors: [expectedError] },
4848
{
4949
code: '<Link />',
5050
errors: [expectedError],

src/rules/anchor-has-content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
if (hasAccessibleChild(node.parent, elementType)) {
4343
return;
4444
}
45-
if (hasProp(node.attributes, 'aria-label')) {
45+
if (hasProp(node.attributes, 'aria-label') && !hasProp(node.attributes, 'title')) {
4646
return;
4747
}
4848

0 commit comments

Comments
 (0)