eslint-plugin-primer-react 0.7.0 → 0.7.1-rc.04b2811
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -31,6 +31,8 @@ ruleTester.run('no-deprecated-colors', rule, {
|
|
|
31
31
|
`import {Box} from "@primer/components"; <Box color="fg.default">Hello</Box>`,
|
|
32
32
|
`import {hello} from "@primer/components"; hello("colors.text.primary")`,
|
|
33
33
|
`import {themeGet} from "@primer/components"; themeGet("space.text.primary")`,
|
|
34
|
+
`import {themeGet} from "@primer/components"; themeGet(props.backgroundColorThemeValue)`,
|
|
35
|
+
`import {themeGet} from "@primer/components"; themeGet(2)`,
|
|
34
36
|
`import {themeGet} from "@other/design-system"; themeGet("colors.text.primary")`,
|
|
35
37
|
`import {get} from "@other/constants"; get("space.text.primary")`,
|
|
36
38
|
`import {Box} from '@primer/components'; <Box sx={styles}>Hello</Box>`,
|
|
@@ -118,11 +118,18 @@ module.exports = {
|
|
|
118
118
|
return
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
const
|
|
121
|
+
const argument = node.arguments[0]
|
|
122
|
+
// Skip if the argument is not a Literal (themeGet(props.backgroundColor))
|
|
123
|
+
// or a string themeGet(2)
|
|
124
|
+
if (argument.type !== 'Literal' || typeof argument.value !== 'string') {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const [key, ...path] = argument.value.split('.')
|
|
122
129
|
const name = path.join('.')
|
|
123
130
|
|
|
124
131
|
if (['colors', 'shadows'].includes(key) && Object.keys(deprecations).includes(name)) {
|
|
125
|
-
replaceDeprecatedColor(context,
|
|
132
|
+
replaceDeprecatedColor(context, argument, name, str => [key, str].join('.'))
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
}
|