Skip to content

Commit 8e24d66

Browse files
authored
[Breaking] Remove new-color-css-vars-have-fallback (#172)
* cleanup * Create smooth-penguins-exercise.md * cleanup * fix test
1 parent d5025dc commit 8e24d66

10 files changed

+99
-573
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-primer-react": major
3+
---
4+
5+
[Breaking] Remove `new-color-css-vars-have-fallback`

docs/rules/new-color-css-vars-have-fallback.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/rules/new-css-color-vars.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
CSS variables are allowed within the `sx` prop in Primer React components. However, the legacy color CSS variables are
44
deprecated in favor of the new CSS variables introduced in Primitives v8. This rule will warn you if you are using the
5-
deprecated color CSS variables in the `sx` prop, and autofix it including a fallback to the old value.
5+
deprecated color CSS variables in the `sx` prop, and autofix it.
66

77
## Rule Details
88

@@ -36,5 +36,5 @@ one based on the property. We only check `sx` because `stylelint` is used to lin
3636
👍 Examples of **correct** code for this rule:
3737

3838
```jsx
39-
<Button sx={{color: 'var(--fgColor-muted, var(--color-fg-muted))'}}>Test</Button>
39+
<Button sx={{color: 'var(--fgColor-muted)'}}>Test</Button>
4040
```

src/configs/recommended.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = {
1616
'primer-react/a11y-tooltip-interactive-trigger': 'error',
1717
'primer-react/new-color-css-vars': 'error',
1818
'primer-react/a11y-explicit-heading': 'error',
19-
'primer-react/new-color-css-vars-have-fallback': 'error',
2019
'primer-react/no-deprecated-props': 'warn',
2120
},
2221
settings: {

src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module.exports = {
77
'a11y-tooltip-interactive-trigger': require('./rules/a11y-tooltip-interactive-trigger'),
88
'new-color-css-vars': require('./rules/new-color-css-vars'),
99
'a11y-explicit-heading': require('./rules/a11y-explicit-heading'),
10-
'new-color-css-vars-have-fallback': require('./rules/new-color-css-vars-have-fallback'),
1110
'no-deprecated-props': require('./rules/no-deprecated-props'),
1211
},
1312
configs: {

src/rules/__tests__/new-color-css-vars.test.js

Lines changed: 90 additions & 98 deletions
Large diffs are not rendered by default.

src/rules/__tests__/new-css-vars-have-fallback.test.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/rules/new-color-css-vars-have-fallback.js

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/rules/new-color-css-vars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ const reportError = (propertyName, valueNode, context, suggestFix = true) => {
3333
// report the error
3434
context.report({
3535
node: valueNode,
36-
message: `Replace var(${cssVar}) with var(${varObjectForProp.replacement}, var(${cssVar}))`,
36+
message: `Replace var(${cssVar}) with var(${varObjectForProp.replacement})`,
3737
fix: suggestFix
3838
? fixer => {
39-
const fixedString = value.replaceAll(cssVar, `${varObjectForProp.replacement}, var(${cssVar})`)
39+
const fixedString = value.replaceAll(cssVar, `${varObjectForProp.replacement}`)
4040
return fixer.replaceText(valueNode, valueNode.type === 'Literal' ? `'${fixedString}'` : fixedString)
4141
}
4242
: undefined,

0 commit comments

Comments
 (0)