eslint-plugin-primer-react 6.2.0-rc.2c85052 → 7.0.0-rc.0a66f81
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/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/docs/rules/a11y-use-accessible-tooltip.md +47 -0
- package/docs/rules/enforce-css-module-default-import.md +53 -0
- package/package-lock.json +1400 -830
- package/package.json +3 -3
- package/src/configs/recommended.js +2 -1
- package/src/index.js +2 -1
- package/src/rules/__tests__/a11y-use-accessible-tooltip.test.js +59 -0
- package/src/rules/__tests__/enforce-css-module-default-import.js +88 -0
- package/src/rules/__tests__/enforce-css-module-identifier-casing.test.js +10 -0
- package/src/rules/a11y-use-accessible-tooltip.js +148 -0
- package/src/rules/enforce-css-module-default-import.js +62 -0
- package/src/rules/enforce-css-module-identifier-casing.js +12 -2
- package/src/utils/css-modules.js +2 -2
- package/docs/rules/a11y-use-next-tooltip.md +0 -33
- package/src/rules/__tests__/a11y-use-next-tooltip.test.js +0 -61
- package/src/rules/a11y-use-next-tooltip.js +0 -128
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# eslint-plugin-primer-react
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#270](https://github.com/primer/eslint-plugin-primer-react/pull/270) [`17814a2`](https://github.com/primer/eslint-plugin-primer-react/commit/17814a2d77d752b6675e51124fe3c18671837a10) Thanks [@broccolinisoup](https://github.com/broccolinisoup)! - Update a11y-use-next-tooltip to be a11y-use-accessible-tooltip and make the changes accordingly
|
|
4
8
|
|
|
5
9
|
### Minor Changes
|
|
6
10
|
|
|
11
|
+
- [#266](https://github.com/primer/eslint-plugin-primer-react/pull/266) [`90134bc`](https://github.com/primer/eslint-plugin-primer-react/commit/90134bcee073c424e81c53e69632e1518798af93) Thanks [@keithamus](https://github.com/keithamus)! - Add enforce-css-module-default-import rule
|
|
12
|
+
|
|
7
13
|
- [#258](https://github.com/primer/eslint-plugin-primer-react/pull/258) [`83f29f3`](https://github.com/primer/eslint-plugin-primer-react/commit/83f29f339999b9c21d95167bcc2680c1797cbab6) Thanks [@keithamus](https://github.com/keithamus)! - Add enforce-css-module-identifier-casing rule
|
|
8
14
|
|
|
9
15
|
## 6.1.6
|
package/README.md
CHANGED
|
@@ -39,4 +39,4 @@ ESLint rules for Primer React
|
|
|
39
39
|
- [a11y-explicit-heading](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-explicit-heading.md)
|
|
40
40
|
- [a11y-link-in-text-block](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-link-in-text-block.md)
|
|
41
41
|
- [a11y-remove-disable-tooltip](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-remove-disable-tooltip.md)
|
|
42
|
-
- [a11y-use-
|
|
42
|
+
- [a11y-use-accessible-tooltip](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-use-accessible-tooltip.md)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Recommends to use the new accessible tooltip instead of the deprecated one.
|
|
2
|
+
|
|
3
|
+
## Rule details
|
|
4
|
+
|
|
5
|
+
This rule suggests switching to the new accessible tooltip from @primer/react instead of the deprecated version. Deprecated props like wrap, noDelay, and align should also be removed.
|
|
6
|
+
|
|
7
|
+
Note that the new tooltip is intended for interactive elements only, such as buttons and links, whereas the deprecated tooltip could be applied to any element, though it lacks screen reader accessibility. As a result, the autofix for this rule will only work if the deprecated tooltip is on an interactive element. If it is applied to a non-interactive element, please consult your design team for [an alternative approach](https://primer.style/guides/accessibility/tooltip-alternatives).
|
|
8
|
+
|
|
9
|
+
👎 Examples of **incorrect** code for this rule:
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
import {Tooltip} from '@primer/react/deprecated'
|
|
13
|
+
|
|
14
|
+
const App = () => (
|
|
15
|
+
<Tooltip aria-label="This change cannot be undone" direction="w" wrap={true} noDelay={true} align="left">
|
|
16
|
+
<Button onClick={onClick}>Delete</Button>
|
|
17
|
+
</Tooltip>
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
👍 Examples of **correct** code for this rule:
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import {Tooltip} from '@primer/react'
|
|
25
|
+
|
|
26
|
+
const App = () => (
|
|
27
|
+
<Tooltip text="This change cannot be undone" direction="w">
|
|
28
|
+
<Button onClick={onClick}>Delete</Button>
|
|
29
|
+
</Tooltip>
|
|
30
|
+
)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Icon buttons and tooltips
|
|
34
|
+
|
|
35
|
+
Even though the below code is perfectly valid, since icon buttons now come with tooltips by default, it is not required to explicitly use the Tooltip component on icon buttons.
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import {IconButton, Tooltip} from '@primer/react'
|
|
39
|
+
|
|
40
|
+
function ExampleComponent() {
|
|
41
|
+
return (
|
|
42
|
+
<Tooltip text="Search" direction="e">
|
|
43
|
+
<IconButton icon={SearchIcon} aria-label="Search" />
|
|
44
|
+
</Tooltip>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Enforce CSS Module Default Import (enforce-css-module-default-import)
|
|
2
|
+
|
|
3
|
+
CSS Modules should import only the default import. Avoid named imports which can often conflict with other variables (including the function name of the React component) when importing css modules.
|
|
4
|
+
|
|
5
|
+
Additionally, for consistency among the codebase the default import should be consistently named. This rule allows enforcing the name of the default import, which by default expects it to be named either `classes` or be suffixed `Classes`.
|
|
6
|
+
|
|
7
|
+
## Rule details
|
|
8
|
+
|
|
9
|
+
This rule disallows the use of any CSS Module property that does not match the desired casing.
|
|
10
|
+
|
|
11
|
+
👎 Examples of **incorrect** code for this rule:
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
/* eslint primer-react/enforce-css-module-default-import: "error" */
|
|
15
|
+
import {Button} from '@primer/react'
|
|
16
|
+
import {Button as ButtonClass} from './some.module.css' // oops! Conflict!
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
/* eslint primer-react/enforce-css-module-default-import: ["error",{enforceName:"^classes$"}] */
|
|
21
|
+
import {Button} from '@primer/react'
|
|
22
|
+
import classnames from './some.module.css' // This default import should match /^classes$/
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
👍 Examples of **correct** code for this rule:
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
/* eslint primer-react/enforce-css-module-default-import: "error" */
|
|
29
|
+
import {Button} from '@primer/react'
|
|
30
|
+
import classes from './some.module.css'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
/* eslint primer-react/enforce-css-module-default-import: ["error",{enforceName:"^classes$"}] */
|
|
35
|
+
import {Button} from '@primer/react'
|
|
36
|
+
import classes from './some.module.css'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
/* eslint primer-react/enforce-css-module-default-import: ["error",{enforceName:"(^classes$|Classes$)"}] */
|
|
41
|
+
import {Button} from '@primer/react'
|
|
42
|
+
import classes from './some.module.css'
|
|
43
|
+
import sharedClasses from './shared.module.css'
|
|
44
|
+
import utilClasses from './util.module.css'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Options
|
|
48
|
+
|
|
49
|
+
- `enforceName` (default: `.*`)
|
|
50
|
+
|
|
51
|
+
By default, the `enforce-css-module-default-import` rule will allow any name for the default export,
|
|
52
|
+
however in the _recommended_ ruleset this is set to `(^classes$|Classes$)` meaning that the default
|
|
53
|
+
export name must either be exactly `classes` or end in `Classes`, for example `sharedClasses`.
|