eslint-plugin-primer-react 3.0.0 → 4.0.0-rc.2ea2bf7
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/dependabot.yml +10 -0
- package/CHANGELOG.md +14 -0
- package/README.md +2 -0
- package/docs/rules/a11y-explicit-heading.md +37 -0
- package/docs/rules/a11y-tooltip-non-interactive-trigger.md +41 -0
- package/package-lock.json +15480 -0
- package/package.json +4 -4
- package/src/configs/components.js +26 -0
- package/src/configs/recommended.js +7 -9
- package/src/index.js +3 -1
- package/src/rules/__tests__/a11y-explicit-heading.test.js +54 -0
- package/src/rules/__tests__/a11y-tooltip-interactive-trigger.test.js +167 -0
- package/src/rules/a11y-explicit-heading.js +66 -0
- package/src/rules/a11y-tooltip-interactive-trigger.js +179 -0
- package/src/url.js +10 -0
- package/src/utils/__tests__/flatten-components.test.js +62 -0
- package/src/utils/flatten-components.js +17 -0
- package/src/utils/get-jsx-opening-element-attribute.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# eslint-plugin-primer-react
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#51](https://github.com/primer/eslint-plugin-primer-react/pull/51) [`a65aa32`](https://github.com/primer/eslint-plugin-primer-react/commit/a65aa32c612c7fe952ec47bb3d926cf8adae9fab) Thanks [@broccolinisoup](https://github.com/broccolinisoup)! - Add `a11y-tooltip-interactive-trigger`
|
|
8
|
+
|
|
9
|
+
* [#66](https://github.com/primer/eslint-plugin-primer-react/pull/66) [`d1df609`](https://github.com/primer/eslint-plugin-primer-react/commit/d1df609b260505ee9dea1740bc96a3187355d727) Thanks [@TylerJDev](https://github.com/TylerJDev)! - Add `a11y-explicit-heading` rule
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#67](https://github.com/primer/eslint-plugin-primer-react/pull/67) [`4dfdb47`](https://github.com/primer/eslint-plugin-primer-react/commit/4dfdb47b40e7f187573b8203830541b86cc7a953) Thanks [@TylerJDev](https://github.com/TylerJDev)! - \* Updates component mapping, adds `components.js`
|
|
14
|
+
- Bumps `eslint-plugin-github` and `eslint-plugin-jsx-a11y`
|
|
15
|
+
- Fixes bug in `a11y-explicit-heading` when using spread props, or variable for `as`
|
|
16
|
+
|
|
3
17
|
## 3.0.0
|
|
4
18
|
|
|
5
19
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -32,3 +32,5 @@ ESLint rules for Primer React
|
|
|
32
32
|
- [direct-slot-children](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/direct-slot-children.md)
|
|
33
33
|
- [no-deprecated-colors](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-deprecated-colors.md)
|
|
34
34
|
- [no-system-props](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/no-system-props.md)
|
|
35
|
+
- [a11y-tooltip-interactive-trigger](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-tooltip-interactive-trigger.md)
|
|
36
|
+
- [a11y-explicit-heading](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-explicit-heading.md)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
## Require explicit heading level on `<Heading>` component
|
|
2
|
+
|
|
3
|
+
The `Heading` component does not require you to use `as` to specify the heading level, as it will default to an `h2` if one isn't specified. This may lead to inaccessible usage if the default is out of order in the existing heading hierarchy.
|
|
4
|
+
|
|
5
|
+
## Rule Details
|
|
6
|
+
|
|
7
|
+
This rule enforces using `as` on the `<Heading>` component to specify a heading level (`h1`-`h6`). In addition, it enforces `as` usage to only be used for headings.
|
|
8
|
+
|
|
9
|
+
👎 Examples of **incorrect** code for this rule
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
import {Heading} from '@primer/react'
|
|
13
|
+
|
|
14
|
+
<Heading>Heading without explicit heading level</Heading>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`as` must only be for headings (`h1`-`h6`)
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
import {Heading} from '@primer/react'
|
|
21
|
+
|
|
22
|
+
<Heading as="span">Heading component used as "span"</Heading>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
👍 Examples of **correct** code for this rule:
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
import {Heading} from '@primer/react';
|
|
29
|
+
|
|
30
|
+
<Heading as="h2">Heading level 2</Heading>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Options
|
|
34
|
+
|
|
35
|
+
- `skipImportCheck` (default: `false`)
|
|
36
|
+
|
|
37
|
+
By default, the `a11y-explicit-heading` rule will only check for `<Heading>` components imported directly from `@primer/react`. You can disable this behavior by setting `skipImportCheck` to `true`.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
## Rule Details
|
|
2
|
+
|
|
3
|
+
This rule enforces to use interactive elements as tooltip triggers. Interactive elements can be Primer `Button`, `IconButton` and `Link` components or native elements like `button`, `a` with an `href` attribute, `select`, `textarea`, `summary` and `input` (that is not a `hidden` type).
|
|
4
|
+
|
|
5
|
+
👎 Examples of **incorrect** code for this rule:
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
/* eslint primer-react/a11y-tooltip-interactive-trigger: "error" */
|
|
9
|
+
import {Tooltip} from '@primer/react'
|
|
10
|
+
|
|
11
|
+
const App = () => (
|
|
12
|
+
<Tooltip text="Tooltip text">
|
|
13
|
+
<div>Tooltip trigger</div>
|
|
14
|
+
</Tooltip>
|
|
15
|
+
)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
👍 Examples of **correct** code for this rule:
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
/* eslint primer-react/a11y-tooltip-interactive-trigger: "error" */
|
|
22
|
+
import {Tooltip, Button} from '@primer/react'
|
|
23
|
+
|
|
24
|
+
const App = () => (
|
|
25
|
+
<Tooltip text="Supplementary text" type="description">
|
|
26
|
+
<Button
|
|
27
|
+
onClick={() => {
|
|
28
|
+
/* do something */
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
Save
|
|
32
|
+
</Button>
|
|
33
|
+
</Tooltip>
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Options
|
|
38
|
+
|
|
39
|
+
- `skipImportCheck` (default: `false`)
|
|
40
|
+
|
|
41
|
+
By default, the `a11y-tooltip-interactive-trigger` rule will only check for interactive elements in components that are imported from `@primer/react`. You can disable this behavior by setting `skipImportCheck` to `true`. This is used for internal linting in the [primer/react](https://github.com/prime/react) repository.
|