Skip to content

Commit

Permalink
[Breaking] Remove new-color-css-vars-have-fallback (#172)
Browse files Browse the repository at this point in the history
* cleanup

* Create smooth-penguins-exercise.md

* cleanup

* fix test
  • Loading branch information
langermank authored May 13, 2024
1 parent d5025dc commit 8e24d66
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 573 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-penguins-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-primer-react": major
---

[Breaking] Remove `new-color-css-vars-have-fallback`
25 changes: 0 additions & 25 deletions docs/rules/new-color-css-vars-have-fallback.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/rules/new-css-color-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.
deprecated color CSS variables in the `sx` prop, and autofix it.

## Rule Details

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

```jsx
<Button sx={{color: 'var(--fgColor-muted, var(--color-fg-muted))'}}>Test</Button>
<Button sx={{color: 'var(--fgColor-muted)'}}>Test</Button>
```
1 change: 0 additions & 1 deletion src/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = {
'primer-react/a11y-tooltip-interactive-trigger': 'error',
'primer-react/new-color-css-vars': 'error',
'primer-react/a11y-explicit-heading': 'error',
'primer-react/new-color-css-vars-have-fallback': 'error',
'primer-react/no-deprecated-props': 'warn',
},
settings: {
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'a11y-tooltip-interactive-trigger': require('./rules/a11y-tooltip-interactive-trigger'),
'new-color-css-vars': require('./rules/new-color-css-vars'),
'a11y-explicit-heading': require('./rules/a11y-explicit-heading'),
'new-color-css-vars-have-fallback': require('./rules/new-color-css-vars-have-fallback'),
'no-deprecated-props': require('./rules/no-deprecated-props'),
},
configs: {
Expand Down
188 changes: 90 additions & 98 deletions src/rules/__tests__/new-color-css-vars.test.js

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions src/rules/__tests__/new-css-vars-have-fallback.test.js

This file was deleted.

87 changes: 0 additions & 87 deletions src/rules/new-color-css-vars-have-fallback.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/rules/new-color-css-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const reportError = (propertyName, valueNode, context, suggestFix = true) => {
// report the error
context.report({
node: valueNode,
message: `Replace var(${cssVar}) with var(${varObjectForProp.replacement}, var(${cssVar}))`,
message: `Replace var(${cssVar}) with var(${varObjectForProp.replacement})`,
fix: suggestFix
? fixer => {
const fixedString = value.replaceAll(cssVar, `${varObjectForProp.replacement}, var(${cssVar})`)
const fixedString = value.replaceAll(cssVar, `${varObjectForProp.replacement}`)
return fixer.replaceText(valueNode, valueNode.type === 'Literal' ? `'${fixedString}'` : fixedString)
}
: undefined,
Expand Down
Loading

0 comments on commit 8e24d66

Please sign in to comment.