Skip to content

Commit 49155f2

Browse files
authored
Document checkImport option
1 parent 49bf748 commit 49155f2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

docs/rules/no-deprecated-colors.md

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

33
🔧 The `--fix` option on the [ESLint CLI](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
44

5-
[Theming](https://primer.style/react/theming) in Primer React is made possible by a theme object that defines your application's colors, spacing, fonts, and more. The color variables in Primer React's [default theme object](https://primer.style/react/theme-reference) are pulled from [Primer Primitives](https://github.com/primer/primitives). When a color variable is deprecated in Primer Primitives, it's important to remove references to that color variable in your application before it's removed from the library.
5+
[Theming](https://primer.style/react/theming) in Primer React is made possible by a theme object that defines your application's colors, spacing, fonts, and more. The color variables in Primer React's [default theme object](https://primer.style/react/theme-reference) are pulled from [Primer Primitives](https://github.com/primer/primitives). When a color variable is deprecated in Primer Primitives, it's important to remove references to that color variable in your application before it's removed from the library.
66

77
## Rule details
88

99
This rule disallows references to color variables that are deprecated in [Primer Primitives](https://github.com/primer/primitives).
1010

11-
1211
👎 Examples of **incorrect** code for this rule:
1312

1413
```jsx
@@ -21,7 +20,7 @@ const SystemPropExample() = () => <Box color="some.deprecated.color">Incorrect</
2120
const SxPropExample() = () => <Box sx={{color: 'some.deprecated.color'}}>Incorrect</Box>
2221

2322
const ThemeGetExample = styled.div`
24-
color: ${themeGet('some.deprecated.color')};
23+
color: ${themeGet('colors.some.deprecated.color')};
2524
`
2625
```
2726

@@ -37,6 +36,16 @@ const SystemPropExample() = () => <Box color="some.color">Incorrect</Box>
3736
const SxPropExample() = () => <Box sx={{color: 'some.color'}}>Incorrect</Box>
3837

3938
const ThemeGetExample = styled.div`
40-
color: ${themeGet('some.color')};
39+
color: ${themeGet('colors.some.color')};
4140
`
4241
```
42+
43+
## Options
44+
45+
- `checkImport` (default: `true`)
46+
47+
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 `checkImport` to `false`. This is useful for linting custom components that that pass color-related props down to Primer React components.
48+
49+
```
50+
"primer-react/no-deprecated-colors": ["warn", {"checkImport": false}]
51+
```

0 commit comments

Comments
 (0)