Skip to content

Commit 445faf3

Browse files
authored
Update docs
1 parent adc02a2 commit 445faf3

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

docs/rules/no-deprecated-colors.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const SystemPropExample() = () => <Box color="some.deprecated.color">Incorrect</
1919

2020
const SxPropExample() = () => <Box sx={{color: 'some.deprecated.color'}}>Incorrect</Box>
2121

22+
const SxPropExample2() = () => <Box sx={{boxShadow: theme => `0 1px 2px ${theme.colors.some.deprecated.color}`}}>Incorrect</Box>
23+
2224
const ThemeGetExample = styled.div`
2325
color: ${themeGet('colors.some.deprecated.color')};
2426
`
@@ -31,9 +33,11 @@ const ThemeGetExample = styled.div`
3133
import {Box, themeGet} from '@primer/components'
3234
import styled from 'styled-components'
3335

34-
const SystemPropExample() = () => <Box color="some.color">Incorrect</Box>
36+
const SystemPropExample() = () => <Box color="some.color">Correct</Box>
37+
38+
const SxPropExample() = () => <Box sx={{color: 'some.color'}}>Correct</Box>
3539

36-
const SxPropExample() = () => <Box sx={{color: 'some.color'}}>Incorrect</Box>
40+
const SxPropExample2() = () => <Box sx={{boxShadow: theme => `0 1px 2px ${theme.colors.some.color}`}}>Correct</Box>
3741

3842
const ThemeGetExample = styled.div`
3943
color: ${themeGet('colors.some.color')};
@@ -46,7 +50,33 @@ const ThemeGetExample = styled.div`
4650

4751
By default, the `no-deprecated-colors` rule will only check for deprecated colors used in functions and components that are imported from `@primer/components`. You can disable this behavior by setting `skipImportCheck` to `true`. This is useful for linting custom components that pass color-related props down to Primer React components.
4852

53+
```js
54+
/* eslint primer-react/no-deprecated-colors: ["warn", {"skipImportCheck": true}] */
55+
import {Box} from '@primer/components'
4956

57+
function MyBox({color, children}) {
58+
return <Box color={color}>{children}</Box>
59+
}
60+
61+
function App() {
62+
// Enabling `skipImportCheck` will find deprecated colors used like this:
63+
return <MyBox color="text.primary">Hello</MyBox>
64+
}
5065
```
51-
"primer-react/no-deprecated-colors": ["warn", {"skipImportCheck": true}]
66+
67+
- `checkAllStrings` (default: `false`)
68+
69+
If `checkAllStrings` is set to `true`, the `no-deprecated-colors` rule will check for deprecated colors in all strings. This is useful for catching uses of deprecated colors outside system props and the `sx` prop.
70+
71+
```js
72+
/* eslint primer-react/no-deprecated-colors: ["warn", {"checkAllStrings": true}] */
73+
import {Box} from '@primer/components'
74+
75+
function ExampleComponent() {
76+
const styles = {
77+
// Enabling `checkAllStrings` will find deprecated colors used like this:
78+
color: 'text.primary'
79+
}
80+
return <Box sx={styles}>Hello</Box>
81+
}
5282
```

0 commit comments

Comments
 (0)