Skip to content

Commit ae7000a

Browse files
authored
fix: parsing spreads in object expressions (#251)
1 parent 4a1b382 commit ae7000a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/util/ast.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ function parseNodeRecursive(rootNode, childNode, cb, skipConditional = false, is
289289
childNode.properties.forEach((prop) => {
290290
const isUsedByClassNamesPlugin = rootNode.callee && rootNode.callee.name === 'classnames';
291291

292+
if (prop.type === 'SpreadElement') {
293+
// Ignore spread elements
294+
return;
295+
}
296+
292297
if (prop.key.type === 'Identifier' && ignoredKeys.includes(prop.key.name)) {
293298
// Ignore specific keys defined in settings
294299
return;

tests/lib/rules/no-custom-classname.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,14 @@ ruleTester.run("no-custom-classname", rule, {
985985
},
986986
],
987987
},
988+
{
989+
code: `
990+
const obj = { a: 12 };
991+
<div className={{
992+
...obj
993+
}}>Spread inside classname object</div>
994+
`,
995+
},
988996
],
989997

990998
invalid: [

0 commit comments

Comments
 (0)