Skip to content

Commit cfca999

Browse files
Merge branch 'main' into bs/rule-for-tooltip-v2
2 parents 613795b + 5911709 commit cfca999

12 files changed

+1847
-372
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# eslint-plugin-primer-react
22

3+
## 4.0.4
4+
5+
### Patch Changes
6+
7+
- [#122](https://github.com/primer/eslint-plugin-primer-react/pull/122) [`3bc226a`](https://github.com/primer/eslint-plugin-primer-react/commit/3bc226ad0786f9a7a21ce92a63cbba17b8a5b763) Thanks [@lukasoppermann](https://github.com/lukasoppermann)! - New rule: new-color-css-vars-have-fallback: checks that if a new color var is used, it has a fallback value
8+
39
## 4.0.3
410

511
### Patch Changes
@@ -151,7 +157,7 @@
151157
function ExampleComponent() {
152158
const styles = {
153159
// Enabling `checkAllStrings` will find deprecated colors used like this:
154-
color: 'text.primary'
160+
color: 'text.primary',
155161
}
156162
return <Box sx={styles}>Hello</Box>
157163
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Ensure new Primitive v8 color CSS vars have a fallback
2+
3+
This rule is temporary as we begin testing v8 color tokens behind a feature flag. If a color token is used without a fallback, the color will only render if the feature flag is enabled. This rule is an extra safety net to ensure we don't accidentally ship code that relies on the feature flag.
4+
5+
## Rule Details
6+
7+
This rule refers to a JSON file that lists all the new color tokens
8+
9+
```json
10+
["--fgColor-default", "--fgColor-muted", "--fgColor-onEmphasis"]
11+
```
12+
13+
If it finds that one of these tokens is used without a fallback, it will throw an error.
14+
15+
👎 Examples of **incorrect** code for this rule
16+
17+
```jsx
18+
<Button sx={{color: 'var(--fgColor-muted)'}}>Test</Button>
19+
```
20+
21+
👍 Examples of **correct** code for this rule:
22+
23+
```jsx
24+
<Button sx={{color: 'var(--fgColor-muted, var(--color-fg-muted))'}}>Test</Button>
25+
```

0 commit comments

Comments
 (0)