eslint-plugin-primer-react 4.0.2 → 4.0.3-rc.d597dea
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 +6 -0
- package/README.md +1 -0
- package/docs/rules/new-css-color-vars.md +35 -0
- package/package-lock.json +15707 -0
- package/package.json +4 -4
- package/src/configs/recommended.js +1 -0
- package/src/index.js +1 -0
- package/src/rules/__tests__/new-color-css-vars.test.js +132 -0
- package/src/rules/new-color-css-vars.js +106 -0
- package/src/utils/css-variable-map.json +2065 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# eslint-plugin-primer-react
|
|
2
2
|
|
|
3
|
+
## 4.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#81](https://github.com/primer/eslint-plugin-primer-react/pull/81) [`821ef4d`](https://github.com/primer/eslint-plugin-primer-react/commit/821ef4d2a1b87f2418cb9c48bed37b793361b282) Thanks [@langermank](https://github.com/langermank)! - New rule: `new-color-css-vars` to find/replace legacy CSS color vars in sx prop
|
|
8
|
+
|
|
3
9
|
## 4.0.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -34,3 +34,4 @@ ESLint rules for Primer React
|
|
|
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
36
|
- [a11y-explicit-heading](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/a11y-explicit-heading.md)
|
|
37
|
+
- [new-css-color-vars](https://github.com/primer/eslint-plugin-primer-react/blob/main/docs/rules/new-css-color-vars.md)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
## Upgrade legacy color CSS variables to Primitives v8 in sx prop
|
|
2
|
+
|
|
3
|
+
CSS variables are allowed within the `sx` prop in Primer React components. However, the legacy color CSS variables are deprecated in favor of the new CSS variables introduced in Primitives v8. This rule will warn you if you are using the deprecated color CSS variables in the `sx` prop, and autofix it including a fallback to the old value.
|
|
4
|
+
|
|
5
|
+
## Rule Details
|
|
6
|
+
|
|
7
|
+
This rule looks inside the `sx` prop for the following properties:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
'bg',
|
|
11
|
+
'backgroundColor',
|
|
12
|
+
'color',
|
|
13
|
+
'borderColor',
|
|
14
|
+
'borderTopColor',
|
|
15
|
+
'borderRightColor',
|
|
16
|
+
'borderBottomColor',
|
|
17
|
+
'borderLeftColor',
|
|
18
|
+
'border',
|
|
19
|
+
'boxShadow',
|
|
20
|
+
'caretColor'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The rule references a static JSON file called `css-variable-map.json` that matches the old color CSS variables to a new one based on the property. We only check `sx` because `stylelint` is used to lint other forms of CSS-in-JS.
|
|
24
|
+
|
|
25
|
+
👎 Examples of **incorrect** code for this rule
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
<Button sx={{color: 'var(--color-fg-muted)'}}>Test</Button>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
👍 Examples of **correct** code for this rule:
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
<Button sx={{color: 'var(--fgColor-muted, var(--color-fg-muted))'}}>Test</Button>
|
|
35
|
+
```
|