eslint-plugin-primer-react 8.5.0 → 8.5.1-rc.2795276
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/.github/workflows/check-for-changeset.yml +1 -1
- package/.github/workflows/ci.yml +3 -3
- package/.github/workflows/release.yml +3 -3
- package/CHANGELOG.md +6 -0
- package/README.md +18 -5
- package/docs/rules/enforce-button-for-link-with-no-href.md +41 -0
- package/package.json +4 -3
- package/src/index.js +16 -15
- package/src/rules/__tests__/{enforce-button-for-link-with-nohref.test.js → enforce-button-for-link-with-no-href.test.js} +2 -2
- /package/docs/rules/{new-css-color-vars.md → new-color-css-vars.md} +0 -0
- /package/src/rules/{enforce-button-for-link-with-nohref.js → enforce-button-for-link-with-no-href.js} +0 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -9,7 +9,7 @@ jobs:
|
|
|
9
9
|
format:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
12
|
+
- uses: actions/checkout@v6
|
|
13
13
|
- name: Use Node.js
|
|
14
14
|
uses: actions/setup-node@v4
|
|
15
15
|
with:
|
|
@@ -21,7 +21,7 @@ jobs:
|
|
|
21
21
|
test:
|
|
22
22
|
runs-on: ubuntu-latest
|
|
23
23
|
steps:
|
|
24
|
-
- uses: actions/checkout@
|
|
24
|
+
- uses: actions/checkout@v6
|
|
25
25
|
- name: Use Node.js
|
|
26
26
|
uses: actions/setup-node@v4
|
|
27
27
|
with:
|
|
@@ -33,7 +33,7 @@ jobs:
|
|
|
33
33
|
lint:
|
|
34
34
|
runs-on: ubuntu-latest
|
|
35
35
|
steps:
|
|
36
|
-
- uses: actions/checkout@
|
|
36
|
+
- uses: actions/checkout@v6
|
|
37
37
|
- name: Use Node.js
|
|
38
38
|
uses: actions/setup-node@v4
|
|
39
39
|
with:
|
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
runs-on: ubuntu-latest
|
|
21
21
|
steps:
|
|
22
22
|
- name: Checkout repository
|
|
23
|
-
uses: actions/checkout@
|
|
23
|
+
uses: actions/checkout@v6
|
|
24
24
|
with:
|
|
25
25
|
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
|
26
26
|
fetch-depth: 0
|
|
@@ -56,7 +56,7 @@ jobs:
|
|
|
56
56
|
runs-on: ubuntu-latest
|
|
57
57
|
steps:
|
|
58
58
|
- name: Checkout repository
|
|
59
|
-
uses: actions/checkout@
|
|
59
|
+
uses: actions/checkout@v6
|
|
60
60
|
with:
|
|
61
61
|
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
|
62
62
|
fetch-depth: 0
|
|
@@ -106,7 +106,7 @@ jobs:
|
|
|
106
106
|
runs-on: ubuntu-latest
|
|
107
107
|
steps:
|
|
108
108
|
- name: Checkout repository
|
|
109
|
-
uses: actions/checkout@
|
|
109
|
+
uses: actions/checkout@v6
|
|
110
110
|
with:
|
|
111
111
|
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
|
112
112
|
fetch-depth: 0
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# eslint-plugin-primer-react
|
|
2
2
|
|
|
3
|
+
## 8.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#461](https://github.com/primer/eslint-plugin-primer-react/pull/461) [`75ae0a5`](https://github.com/primer/eslint-plugin-primer-react/commit/75ae0a5cb1d4587b5481c8a459033206aae8e5c3) Thanks [@joshfarrant](https://github.com/joshfarrant)! - Export `enforce-button-for-link-with-no-href` rule, which flags `Link` components which don't have a `href`.
|
|
8
|
+
|
|
3
9
|
## 8.5.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -31,13 +31,26 @@ ESLint rules for Primer React
|
|
|
31
31
|
|
|
32
32
|
## Rules
|
|
33
33
|
|
|
34
|
-
- [direct-slot-children](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/direct-slot-children.md)
|
|
35
|
-
- [no-system-props](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-system-props.md)
|
|
36
|
-
- [new-css-color-vars](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/new-css-color-vars.md)
|
|
37
|
-
- [no-deprecated-props](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-deprecated-props.md)
|
|
38
|
-
- [a11y-tooltip-interactive-trigger](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-tooltip-interactive-trigger.md)
|
|
39
34
|
- [a11y-explicit-heading](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-explicit-heading.md)
|
|
40
35
|
- [a11y-link-in-text-block](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-link-in-text-block.md)
|
|
36
|
+
- [a11y-no-duplicate-form-labels](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-no-duplicate-form-labels.md)
|
|
37
|
+
- [a11y-no-title-usage](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-no-title-usage.md)
|
|
41
38
|
- [a11y-remove-disable-tooltip](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-remove-disable-tooltip.md)
|
|
39
|
+
- [a11y-tooltip-interactive-trigger](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-tooltip-interactive-trigger.md)
|
|
42
40
|
- [a11y-use-accessible-tooltip](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-use-accessible-tooltip.md)
|
|
41
|
+
- [direct-slot-children](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/direct-slot-children.md)
|
|
42
|
+
- [enforce-button-for-link-with-no-href](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/enforce-button-for-link-with-no-href.md)
|
|
43
|
+
- [enforce-css-module-default-import](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/enforce-css-module-default-import.md)
|
|
44
|
+
- [enforce-css-module-identifier-casing](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/enforce-css-module-identifier-casing.md)
|
|
45
|
+
- [new-color-css-vars](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/new-color-css-vars.md)
|
|
46
|
+
- [no-deprecated-entrypoints](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-deprecated-entrypoints.md)
|
|
43
47
|
- [no-deprecated-experimental-components](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-deprecated-experimental-components.md)
|
|
48
|
+
- [no-deprecated-props](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-deprecated-props.md)
|
|
49
|
+
- [no-system-props](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-system-props.md)
|
|
50
|
+
- [no-unnecessary-components](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-unnecessary-components.md)
|
|
51
|
+
- [no-use-responsive-value](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-use-responsive-value.md)
|
|
52
|
+
- [no-wildcard-imports](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-wildcard-imports.md)
|
|
53
|
+
- [prefer-action-list-item-onselect](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/prefer-action-list-item-onselect.md)
|
|
54
|
+
- [spread-props-first](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/spread-props-first.md)
|
|
55
|
+
- [use-deprecated-from-deprecated](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/use-deprecated-from-deprecated.md)
|
|
56
|
+
- [use-styled-react-import](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/use-styled-react-import.md)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Enforce Button for Link with No href (enforce-button-for-link-with-no-href)
|
|
2
|
+
|
|
3
|
+
Primer's `Link` component enables users to navigate between pages. Rendering it without an `href` makes the element behave like a button without the correct semantics, which negatively impacts accessibility. Use the `Button` component to trigger an action, or ensure the `Link` has a valid `href`.
|
|
4
|
+
|
|
5
|
+
## Rule details
|
|
6
|
+
|
|
7
|
+
This rule reports any `Link` from `@primer/react` that does not include an `href` prop.
|
|
8
|
+
|
|
9
|
+
👎 Examples of **incorrect** code for this rule:
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
/* eslint primer-react/enforce-button-for-link-with-no-href: "error" */
|
|
13
|
+
import {Link} from '@primer/react'
|
|
14
|
+
;<Link onClick={handleClick}>Save changes</Link>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
/* eslint primer-react/enforce-button-for-link-with-no-href: "error" */
|
|
19
|
+
import {Link} from '@primer/react'
|
|
20
|
+
;<Link className="text-right">Learn more</Link>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
👍 Examples of **correct** code for this rule:
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
/* eslint primer-react/enforce-button-for-link-with-no-href: "error" */
|
|
27
|
+
import {Link} from '@primer/react'
|
|
28
|
+
;<Link href="https://primer.style/react">Read the docs</Link>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
/* eslint primer-react/enforce-button-for-link-with-no-href: "error" */
|
|
33
|
+
import {Button, Link} from '@primer/react'
|
|
34
|
+
|
|
35
|
+
<Button onClick={handleClick}>Save changes</Button>
|
|
36
|
+
<Link href={issueUrl}>View issue</Link>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Options
|
|
40
|
+
|
|
41
|
+
This rule has no options.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-primer-react",
|
|
3
|
-
"version": "8.5.
|
|
3
|
+
"version": "8.5.1-rc.2795276",
|
|
4
4
|
"description": "ESLint rules for Primer React",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"@github/markdownlint-github": "^0.6.3",
|
|
47
47
|
"@github/prettier-config": "0.0.6",
|
|
48
48
|
"@types/jest": "^30.0.0",
|
|
49
|
-
"@
|
|
49
|
+
"@types/node": "^24.10.1",
|
|
50
|
+
"@typescript-eslint/rule-tester": "8.48.1",
|
|
50
51
|
"eslint": "^9.0.0",
|
|
51
52
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
52
53
|
"eslint-plugin-filenames": "^1.3.2",
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"eslint-plugin-prettier": "^5.5.4",
|
|
57
58
|
"globals": "^16.3.0",
|
|
58
59
|
"jest": "^30.0.5",
|
|
59
|
-
"markdownlint-cli2": "^0.
|
|
60
|
+
"markdownlint-cli2": "^0.20.0",
|
|
60
61
|
"markdownlint-cli2-formatter-pretty": "^0.0.9"
|
|
61
62
|
},
|
|
62
63
|
"prettier": "@github/prettier-config"
|
package/src/index.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
rules: {
|
|
3
|
-
'direct-slot-children': require('./rules/direct-slot-children'),
|
|
4
|
-
'no-deprecated-entrypoints': require('./rules/no-deprecated-entrypoints'),
|
|
5
|
-
'no-system-props': require('./rules/no-system-props'),
|
|
6
|
-
'no-deprecated-experimental-components': require('./rules/no-deprecated-experimental-components'),
|
|
7
|
-
'a11y-tooltip-interactive-trigger': require('./rules/a11y-tooltip-interactive-trigger'),
|
|
8
|
-
'new-color-css-vars': require('./rules/new-color-css-vars'),
|
|
9
3
|
'a11y-explicit-heading': require('./rules/a11y-explicit-heading'),
|
|
10
|
-
'no-deprecated-props': require('./rules/no-deprecated-props'),
|
|
11
4
|
'a11y-link-in-text-block': require('./rules/a11y-link-in-text-block'),
|
|
5
|
+
'a11y-no-duplicate-form-labels': require('./rules/a11y-no-duplicate-form-labels'),
|
|
6
|
+
'a11y-no-title-usage': require('./rules/a11y-no-title-usage'),
|
|
12
7
|
'a11y-remove-disable-tooltip': require('./rules/a11y-remove-disable-tooltip'),
|
|
8
|
+
'a11y-tooltip-interactive-trigger': require('./rules/a11y-tooltip-interactive-trigger'),
|
|
13
9
|
'a11y-use-accessible-tooltip': require('./rules/a11y-use-accessible-tooltip'),
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
10
|
+
'direct-slot-children': require('./rules/direct-slot-children'),
|
|
11
|
+
'enforce-button-for-link-with-no-href': require('./rules/enforce-button-for-link-with-no-href'),
|
|
12
|
+
'enforce-css-module-default-import': require('./rules/enforce-css-module-default-import'),
|
|
13
|
+
'enforce-css-module-identifier-casing': require('./rules/enforce-css-module-identifier-casing'),
|
|
14
|
+
'new-color-css-vars': require('./rules/new-color-css-vars'),
|
|
15
|
+
'no-deprecated-entrypoints': require('./rules/no-deprecated-entrypoints'),
|
|
16
|
+
'no-deprecated-experimental-components': require('./rules/no-deprecated-experimental-components'),
|
|
17
|
+
'no-deprecated-props': require('./rules/no-deprecated-props'),
|
|
18
|
+
'no-system-props': require('./rules/no-system-props'),
|
|
18
19
|
'no-unnecessary-components': require('./rules/no-unnecessary-components'),
|
|
20
|
+
'no-use-responsive-value': require('./rules/no-use-responsive-value'),
|
|
21
|
+
'no-wildcard-imports': require('./rules/no-wildcard-imports'),
|
|
19
22
|
'prefer-action-list-item-onselect': require('./rules/prefer-action-list-item-onselect'),
|
|
20
|
-
'enforce-css-module-identifier-casing': require('./rules/enforce-css-module-identifier-casing'),
|
|
21
|
-
'enforce-css-module-default-import': require('./rules/enforce-css-module-default-import'),
|
|
22
|
-
'use-styled-react-import': require('./rules/use-styled-react-import'),
|
|
23
23
|
'spread-props-first': require('./rules/spread-props-first'),
|
|
24
|
-
'
|
|
24
|
+
'use-deprecated-from-deprecated': require('./rules/use-deprecated-from-deprecated'),
|
|
25
|
+
'use-styled-react-import': require('./rules/use-styled-react-import'),
|
|
25
26
|
},
|
|
26
27
|
configs: {
|
|
27
28
|
recommended: require('./configs/recommended'),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const rule = require('../enforce-button-for-link-with-
|
|
1
|
+
const rule = require('../enforce-button-for-link-with-no-href')
|
|
2
2
|
const {RuleTester} = require('eslint')
|
|
3
3
|
|
|
4
4
|
const ruleTester = new RuleTester({
|
|
@@ -13,7 +13,7 @@ const ruleTester = new RuleTester({
|
|
|
13
13
|
},
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
ruleTester.run('enforce-button-for-link-with-
|
|
16
|
+
ruleTester.run('enforce-button-for-link-with-no-href', rule, {
|
|
17
17
|
valid: [
|
|
18
18
|
// Link with href attribute
|
|
19
19
|
`import {Link} from '@primer/react';
|
|
File without changes
|
|
File without changes
|