Skip to content

Commit 465d99c

Browse files
authored
Rename checkImport to skipImportCheck
1 parent 5882532 commit 465d99c

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

docs/rules/no-deprecated-colors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const ThemeGetExample = styled.div`
4242

4343
## Options
4444

45-
- `checkImport` (default: `true`)
45+
- `skipImportCheck` (default: `false`)
4646

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.
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 `skipImportCheck` to `true`. This is useful for linting custom components that that pass color-related props down to Primer React components.
4848

4949
```
50-
"primer-react/no-deprecated-colors": ["warn", {"checkImport": false}]
50+
"primer-react/no-deprecated-colors": ["warn", {"skipImportCheck": true}]
5151
```

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rules/__tests__/no-deprecated-colors.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ruleTester.run('no-deprecated-colors', rule, {
4646
{
4747
code: `import {Box} from "../components"; function Example() { return <Box color="text.primary">Hello</Box> }`,
4848
output: `import {Box} from "../components"; function Example() { return <Box color="fg.default">Hello</Box> }`,
49-
options: [{checkImport: false}],
49+
options: [{skipImportCheck: true}],
5050
errors: [
5151
{
5252
message: '"text.primary" is deprecated. Use "fg.default" instead.'

src/rules/no-deprecated-colors.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
{
1111
type: 'object',
1212
properties: {
13-
checkImport: {
13+
skipImportCheck: {
1414
type: 'boolean'
1515
}
1616
},
@@ -19,14 +19,14 @@ module.exports = {
1919
]
2020
},
2121
create(context) {
22-
// If `shouldCheckImport` is true, this rule will only check for deprecated colors
23-
// used in functions and components that are imported from `@primer/components`.
24-
const shouldCheckImport = context.options[0] ? context.options[0].checkImport : true
22+
// If `skipImportCheck` is true, this rule will check for deprecated colors
23+
// used in any components (not just ones that are imported from `@primer/components`).
24+
const skipImportCheck = context.options[0] ? context.options[0].skipImportCheck : false
2525

2626
return {
2727
JSXOpeningElement(node) {
2828
// Skip if component was not imported from @primer/components
29-
if (shouldCheckImport && !isPrimerComponent(node.name, context.getScope(node))) {
29+
if (!skipImportCheck && !isPrimerComponent(node.name, context.getScope(node))) {
3030
return
3131
}
3232

@@ -65,7 +65,7 @@ module.exports = {
6565
// Skip if not calling the `themeGet` or `get` function
6666
// `get` is the internal version of `themeGet` that's used in the primer/react repository
6767
if (
68-
!isThemeGet(node.callee, context.getScope(node), shouldCheckImport) &&
68+
!isThemeGet(node.callee, context.getScope(node), skipImportCheck) &&
6969
!isGet(node.callee, context.getScope(node))
7070
) {
7171
return
@@ -113,8 +113,8 @@ function isPrimerComponent(identifier, scope) {
113113
return isImportedFrom(/^@primer\/components/, identifier, scope)
114114
}
115115

116-
function isThemeGet(identifier, scope, shouldCheckImport = true) {
117-
if (shouldCheckImport) {
116+
function isThemeGet(identifier, scope, skipImportCheck = false) {
117+
if (!skipImportCheck) {
118118
return isImportedFrom(/^@primer\/components/, identifier, scope) && identifier.name === 'themeGet'
119119
}
120120

0 commit comments

Comments
 (0)