eslint-plugin-primer-react 5.2.0 → 5.2.1-rc.1fbdfd0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -115,6 +115,16 @@ ruleTester.run('a11y-link-in-text-block', rule, {
|
|
|
115
115
|
includes:
|
|
116
116
|
</Heading>
|
|
117
117
|
`,
|
|
118
|
+
`import {Link} from '@primer/react';
|
|
119
|
+
<p>bla blah
|
|
120
|
+
<Link className={styles.someClass}>Link text</Link>
|
|
121
|
+
</p>
|
|
122
|
+
`,
|
|
123
|
+
`import {Link} from '@primer/react';
|
|
124
|
+
<p>bla blah
|
|
125
|
+
<Link className='some-class'>Link text</Link>
|
|
126
|
+
</p>
|
|
127
|
+
`,
|
|
118
128
|
],
|
|
119
129
|
invalid: [
|
|
120
130
|
{
|
|
@@ -4,6 +4,9 @@ const {getJSXOpeningElementAttribute} = require('../utils/get-jsx-opening-elemen
|
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
meta: {
|
|
7
|
+
docs: {
|
|
8
|
+
url: require('../url')(module),
|
|
9
|
+
},
|
|
7
10
|
type: 'problem',
|
|
8
11
|
schema: [
|
|
9
12
|
{
|
|
@@ -15,7 +18,8 @@ module.exports = {
|
|
|
15
18
|
},
|
|
16
19
|
],
|
|
17
20
|
messages: {
|
|
18
|
-
linkInTextBlock:
|
|
21
|
+
linkInTextBlock:
|
|
22
|
+
'Links should have the inline prop if it appear in a text block and only uses color to distinguish itself from surrounding text.',
|
|
19
23
|
},
|
|
20
24
|
},
|
|
21
25
|
create(context) {
|
|
@@ -28,6 +32,10 @@ module.exports = {
|
|
|
28
32
|
name === 'Link' &&
|
|
29
33
|
node.parent.children
|
|
30
34
|
) {
|
|
35
|
+
// Skip if Link has className because we cannot deduce what styles are applied.
|
|
36
|
+
const classNameAttribute = getJSXOpeningElementAttribute(node.openingElement, 'className')
|
|
37
|
+
if (classNameAttribute) return
|
|
38
|
+
|
|
31
39
|
let siblings = node.parent.children
|
|
32
40
|
const parentName = node.parent.openingElement?.name?.name
|
|
33
41
|
// Skip if Link is nested inside of a heading.
|