eslint-plugin-primer-react 7.0.0-rc.414f409 → 7.0.0-rc.449d4ba
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-primer-react",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.449d4ba",
|
|
4
4
|
"description": "ESLint rules for Primer React",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"eslint-traverse": "^1.0.0",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
36
|
"styled-system": "^5.1.5",
|
|
37
|
-
"@typescript-eslint/utils": "
|
|
37
|
+
"@typescript-eslint/utils": "8.24.0",
|
|
38
38
|
"typescript": "^5.5.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"eslint": "^8.42.0",
|
|
46
46
|
"eslint-plugin-prettier": "^5.2.1",
|
|
47
47
|
"jest": "^29.7.0",
|
|
48
|
-
"markdownlint-cli2": "^0.
|
|
48
|
+
"markdownlint-cli2": "^0.17.1",
|
|
49
49
|
"markdownlint-cli2-formatter-pretty": "^0.0.7",
|
|
50
50
|
"@typescript-eslint/rule-tester": "7.16.0",
|
|
51
51
|
"@types/jest": "^29.5.13"
|
|
@@ -67,6 +67,22 @@ ruleTester.run('non-interactive-tooltip-trigger', rule, {
|
|
|
67
67
|
</Link>
|
|
68
68
|
</Tooltip>
|
|
69
69
|
`,
|
|
70
|
+
`
|
|
71
|
+
import {Tooltip, Link} from '@primer/react';
|
|
72
|
+
<Tooltip aria-label="product" direction="e">
|
|
73
|
+
<Link to={productLink}>
|
|
74
|
+
Product
|
|
75
|
+
</Link>
|
|
76
|
+
</Tooltip>
|
|
77
|
+
`,
|
|
78
|
+
`
|
|
79
|
+
import {Tooltip, Link} from '@primer/react';
|
|
80
|
+
<Tooltip aria-label="product" direction="e">
|
|
81
|
+
<Link to="https://github.com">
|
|
82
|
+
Product
|
|
83
|
+
</Link>
|
|
84
|
+
</Tooltip>
|
|
85
|
+
`,
|
|
70
86
|
],
|
|
71
87
|
invalid: [
|
|
72
88
|
{
|
|
@@ -23,7 +23,7 @@ const isAnchorTag = el => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const isJSXValue = attributes => {
|
|
26
|
-
const node = attributes.find(attribute => propName(attribute) === 'href')
|
|
26
|
+
const node = attributes.find(attribute => propName(attribute) === 'href' || propName(attribute))
|
|
27
27
|
const isJSXExpression = node.value.type === 'JSXExpressionContainer' && node && typeof getPropValue(node) === 'string'
|
|
28
28
|
|
|
29
29
|
return isJSXExpression
|
|
@@ -31,8 +31,14 @@ const isJSXValue = attributes => {
|
|
|
31
31
|
|
|
32
32
|
const isInteractiveAnchor = child => {
|
|
33
33
|
const hasHref = getJSXOpeningElementAttribute(child.openingElement, 'href')
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const hasTo = getJSXOpeningElementAttribute(child.openingElement, 'to')
|
|
35
|
+
|
|
36
|
+
if (!hasHref && !hasTo) return false
|
|
37
|
+
|
|
38
|
+
const href = hasHref
|
|
39
|
+
? getJSXOpeningElementAttribute(child.openingElement, 'href').value.value
|
|
40
|
+
: getJSXOpeningElementAttribute(child.openingElement, 'to').value.value
|
|
41
|
+
|
|
36
42
|
const hasJSXValue = isJSXValue(child.openingElement.attributes)
|
|
37
43
|
const isAnchorInteractive = (typeof href === 'string' && href !== '') || hasJSXValue
|
|
38
44
|
|