Skip to content

Commit a1b3f23

Browse files
committed
fix: remove title from the anchor has content rule
1 parent a7d1a12 commit a1b3f23

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

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

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

docs/rules/anchor-has-content.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Enforce that anchors have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the `aria-hidden` prop. Refer to the references to learn about why this is important.
88

9-
Alternatively, you may use the `title` prop or the `aria-label` prop.
9+
Alternatively, you may use the `aria-label` prop.
1010

1111
## Rule options
1212

@@ -47,7 +47,6 @@ return (
4747
<a>Anchor Content!</a>
4848
<a><TextWrapper /></a>
4949
<a dangerouslySetInnerHTML={{ __html: 'foo' }} />
50-
<a title='foo' />
5150
<a aria-label='foo' />
5251
```
5352

src/rules/anchor-has-content.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Rule Definition
88
// ----------------------------------------------------------------------------
99

10-
import { hasAnyProp } from 'jsx-ast-utils';
10+
import { hasProp } from 'jsx-ast-utils';
1111

1212
import getElementType from '../util/getElementType';
1313
import { arraySchema, generateObjSchema } from '../util/schemas';
@@ -42,7 +42,7 @@ export default {
4242
if (hasAccessibleChild(node.parent, elementType)) {
4343
return;
4444
}
45-
if (hasAnyProp(node.attributes, ['title', 'aria-label'])) {
45+
if (hasProp(node.attributes, 'aria-label')) {
4646
return;
4747
}
4848

0 commit comments

Comments
 (0)