eslint-plugin-primer-react 4.0.0-rc.b9f7dc6 → 4.0.1-rc.5e09109
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 +21 -0
- package/README.md +1 -0
- package/docs/rules/a11y-explicit-heading.md +37 -0
- package/package-lock.json +1548 -669
- package/package.json +4 -4
- package/src/configs/components.js +23 -0
- package/src/configs/recommended.js +6 -9
- package/src/index.js +2 -1
- package/src/rules/__tests__/a11y-explicit-heading.test.js +63 -0
- package/src/rules/__tests__/a11y-tooltip-interactive-trigger.test.js +57 -6
- package/src/rules/__tests__/direct-slot-children.test.js +20 -0
- package/src/rules/a11y-explicit-heading.js +66 -0
- package/src/rules/a11y-tooltip-interactive-trigger.js +37 -28
- package/src/rules/direct-slot-children.js +2 -1
- 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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
# eslint-plugin-primer-react
|
|
2
2
|
|
|
3
|
+
## 4.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#74](https://github.com/primer/eslint-plugin-primer-react/pull/74) [`c07df5c`](https://github.com/primer/eslint-plugin-primer-react/commit/c07df5c067e2a980bcd373d1c992a2123ef70c5c) Thanks [@TylerJDev](https://github.com/TylerJDev)! - Adds support for `MarkdownEditor.Footer` in `direct-slot-children` rule
|
|
8
|
+
|
|
3
9
|
## 4.0.0
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
|
6
12
|
|
|
7
13
|
- [#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
14
|
|
|
15
|
+
* [#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
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#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`
|
|
20
|
+
- Bumps `eslint-plugin-github` and `eslint-plugin-jsx-a11y`
|
|
21
|
+
- Fixes bug in `a11y-explicit-heading` when using spread props, or variable for `as`
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#72](https://github.com/primer/eslint-plugin-primer-react/pull/72) [`522b9cc`](https://github.com/primer/eslint-plugin-primer-react/commit/522b9ccbcfb26d18f2ea8b2514a6a7975480aaa7) Thanks [@TylerJDev](https://github.com/TylerJDev)! - Removes `Link`, `Spinner` and `TabNav.Link` from component mapping
|
|
26
|
+
|
|
27
|
+
* [#73](https://github.com/primer/eslint-plugin-primer-react/pull/73) [`974d9e8`](https://github.com/primer/eslint-plugin-primer-react/commit/974d9e85c7460a05eb0345086b340b650700d24d) Thanks [@TylerJDev](https://github.com/TylerJDev)! - \* Fixes `nonInteractiveLink` rule for links that pass values through JSX rather than a string
|
|
28
|
+
- Adds optional chaining to `getJSXOpeningElementAttribute` to avoid error when no `name` is present
|
|
29
|
+
|
|
9
30
|
## 3.0.0
|
|
10
31
|
|
|
11
32
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -33,3 +33,4 @@ ESLint rules for Primer React
|
|
|
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
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`.
|