Skip to content

Commit

Permalink
Don't replace arithmetic expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Jun 18, 2023
1 parent 16abf28 commit 55e6bbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ ruleTester.run('prefer-custom-properties', preferCustomProperties, {
`,
errors: [{ messageId: 'refactor' }],
},
{
name: 'tagged template expression that does arithmetic with the `theme` property',
code: `
const styles = (theme) => css\`
z-index: \${theme.zIndex.absolute + 1};
\`;
`,
errors: [{ messageId: 'refactor' }],
},
{
name: 'tagged template expression with conditional `theme` properties',
code: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const preferCustomProperties = createRule({
}

// Computed expressions cannot be auto-fixed.
if (computed) {
if (computed || node.parent?.type === 'BinaryExpression') {
context.report({
node,
messageId: 'refactor',
Expand Down

0 comments on commit 55e6bbf

Please sign in to comment.