diff --git a/lib/rules/classnames-order.js b/lib/rules/classnames-order.js index d1e324fe..c877be74 100644 --- a/lib/rules/classnames-order.js +++ b/lib/rules/classnames-order.js @@ -127,8 +127,10 @@ module.exports = { }); return; case 'ObjectExpression': + const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; + arg.properties.forEach((prop) => { - sortNodeArgumentValue(node, prop.key); + sortNodeArgumentValue(node, isUsedByClassNamesPlugin ? prop.key : prop.value); }); return; case 'Literal': diff --git a/lib/rules/enforces-negative-arbitrary-values.js b/lib/rules/enforces-negative-arbitrary-values.js index 5f297f03..ad5b99fe 100644 --- a/lib/rules/enforces-negative-arbitrary-values.js +++ b/lib/rules/enforces-negative-arbitrary-values.js @@ -102,8 +102,10 @@ module.exports = { }); return; case 'ObjectExpression': + const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; + arg.properties.forEach((prop) => { - parseForNegativeArbitraryClassNames(node, prop.key); + parseForNegativeArbitraryClassNames(node, isUsedByClassNamesPlugin ? prop.key : prop.value); }); return; case 'Literal': diff --git a/lib/rules/enforces-shorthand.js b/lib/rules/enforces-shorthand.js index b3896885..97c8e335 100644 --- a/lib/rules/enforces-shorthand.js +++ b/lib/rules/enforces-shorthand.js @@ -154,8 +154,10 @@ module.exports = { }); return; case 'ObjectExpression': + const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; + arg.properties.forEach((prop) => { - parseForShorthandCandidates(node, prop.key); + parseForShorthandCandidates(node, isUsedByClassNamesPlugin ? prop.key : prop.value); }); return; case 'Literal': diff --git a/lib/rules/no-arbitrary-value.js b/lib/rules/no-arbitrary-value.js index e448e410..7b766e0d 100644 --- a/lib/rules/no-arbitrary-value.js +++ b/lib/rules/no-arbitrary-value.js @@ -101,8 +101,10 @@ module.exports = { }); return; case 'ObjectExpression': + const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; + arg.properties.forEach((prop) => { - parseForArbitraryValues(node, prop.key); + parseForArbitraryValues(node, isUsedByClassNamesPlugin ? prop.key : prop.value); }); return; case 'Literal': diff --git a/lib/util/ast.js b/lib/util/ast.js index 225f2ba1..ae62098f 100644 --- a/lib/util/ast.js +++ b/lib/util/ast.js @@ -209,7 +209,15 @@ function parseNodeRecursive(node, arg, cb, skipConditional = false, isolate = fa return; case 'ObjectExpression': arg.properties.forEach((prop) => { - parseNodeRecursive(node, prop.key, cb, skipConditional, forceIsolation); + const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; + + parseNodeRecursive( + node, + isUsedByClassNamesPlugin ? prop.key : prop.value, + cb, + skipConditional, + forceIsolation + ); }); return; case 'Literal': diff --git a/tests/lib/rules/classnames-order.js b/tests/lib/rules/classnames-order.js index 76802585..59e253a0 100644 --- a/tests/lib/rules/classnames-order.js +++ b/tests/lib/rules/classnames-order.js @@ -507,6 +507,20 @@ ruleTester.run("classnames-order", rule, { ], errors: errors, }, + { + code: `cva({ + primary: ["absolute bottom-0 w-full h-[70px] flex flex-col"], + })`, + output: `cva({ + primary: ["absolute bottom-0 flex h-[70px] w-full flex-col"], + })`, + options: [ + { + callees: ["cva"], + }, + ], + errors: errors, + }, { code: `
clsx
`, output: `
clsx
`, diff --git a/tests/lib/rules/enforces-shorthand.js b/tests/lib/rules/enforces-shorthand.js index 4fe139d6..a6fa258d 100644 --- a/tests/lib/rules/enforces-shorthand.js +++ b/tests/lib/rules/enforces-shorthand.js @@ -491,5 +491,19 @@ ruleTester.run("shorthands", rule, { `, errors: [generateError(["p-2", "pl-2", "pr-2"], "p-2")], }, + { + code: `cva({ + primary: ["border-l-0 border-r-0"], + });`, + output: `cva({ + primary: ["border-x-0"], + });`, + options: [ + { + callees: ["cva"], + }, + ], + errors: [generateError(["border-l-0", "border-r-0"], "border-x-0")], + }, ], }); diff --git a/tests/lib/rules/no-arbitrary-value.js b/tests/lib/rules/no-arbitrary-value.js index 1959c5e6..222759e3 100644 --- a/tests/lib/rules/no-arbitrary-value.js +++ b/tests/lib/rules/no-arbitrary-value.js @@ -93,16 +93,11 @@ ruleTester.run("no-arbitrary-value", rule, { { code: `