Skip to content

Commit efb6db8

Browse files
committed
Skip running rule if argument is non-literal, non-string value
1 parent 9b70fb9 commit efb6db8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/rules/no-deprecated-colors.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,18 @@ module.exports = {
118118
return
119119
}
120120

121-
const [key, ...path] = node.arguments[0].value.split('.')
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 false
126+
}
127+
128+
const [key, ...path] = argument.value.split('.')
122129
const name = path.join('.')
123130

124131
if (['colors', 'shadows'].includes(key) && Object.keys(deprecations).includes(name)) {
125-
replaceDeprecatedColor(context, node.arguments[0], name, str => [key, str].join('.'))
132+
replaceDeprecatedColor(context, argument, name, str => [key, str].join('.'))
126133
}
127134
}
128135
}

0 commit comments

Comments
 (0)