Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/core-parts/finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,22 @@ export function findTargetClassNameNodes(ast: AST, options: ResolvedOptions): Cl
recursiveProps = ['left', 'right'];
break;
}
case 'CallExpression': {
case 'CallExpression':
case 'OptionalCallExpression': {
recursiveProps = ['arguments'];
break;
}
case 'ConditionalExpression':
case 'IfStatement': {
recursiveProps = ['consequent', 'alternate'];
break;
}
case 'ChainExpression':
case 'ExpressionStatement':
case 'JSXExpressionContainer': {
recursiveProps = ['expression'];
break;
}
case 'ConditionalExpression':
case 'IfStatement': {
recursiveProps = ['consequent', 'alternate'];
break;
}
case 'ExportDefaultDeclaration':
case 'ExportNamedDeclaration': {
recursiveProps = ['declaration'];
Expand Down
36 changes: 36 additions & 0 deletions tests/babel/others/absolute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,42 @@ function Foo() {
}
return elem;
}
`,
options: {
printWidth: 80,
},
},
{
name: 'JSX mapped from object references including optional chaining',
input: `
function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div key={index} className="lorem ipsum dolor sit amet consectetur adipiscing elit proin ex massa hendrerit eu posuere eu volutpat id neque pellentesque">
content
</div>
))}
</div>
);
}
`,
output: `function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div
key={index}
className="lorem ipsum dolor sit amet consectetur adipiscing elit
proin ex massa hendrerit eu posuere eu volutpat id neque
pellentesque"
>
content
</div>
))}
</div>
);
}
`,
options: {
printWidth: 80,
Expand Down
35 changes: 35 additions & 0 deletions tests/babel/others/relative.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,41 @@ function Foo() {
}
return elem;
}
`,
options: {
printWidth: 80,
},
},
{
name: 'JSX mapped from object references including optional chaining',
input: `
function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div key={index} className="lorem ipsum dolor sit amet consectetur adipiscing elit proin ex massa hendrerit eu posuere eu volutpat id neque pellentesque">
content
</div>
))}
</div>
);
}
`,
output: `function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div
key={index}
className="lorem ipsum dolor sit amet consectetur adipiscing elit proin ex massa hendrerit
eu posuere eu volutpat id neque pellentesque"
>
content
</div>
))}
</div>
);
}
`,
options: {
printWidth: 80,
Expand Down
36 changes: 36 additions & 0 deletions tests/typescript/others/absolute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,42 @@ function Foo() {
}
return elem;
}
`,
options: {
printWidth: 80,
},
},
{
name: 'JSX mapped from object references including optional chaining',
input: `
function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div key={index} className="lorem ipsum dolor sit amet consectetur adipiscing elit proin ex massa hendrerit eu posuere eu volutpat id neque pellentesque">
content
</div>
))}
</div>
);
}
`,
output: `function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div
key={index}
className="lorem ipsum dolor sit amet consectetur adipiscing elit
proin ex massa hendrerit eu posuere eu volutpat id neque
pellentesque"
>
content
</div>
))}
</div>
);
}
`,
options: {
printWidth: 80,
Expand Down
35 changes: 35 additions & 0 deletions tests/typescript/others/relative.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,41 @@ function Foo() {
}
return elem;
}
`,
options: {
printWidth: 80,
},
},
{
name: 'JSX mapped from object references including optional chaining',
input: `
function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div key={index} className="lorem ipsum dolor sit amet consectetur adipiscing elit proin ex massa hendrerit eu posuere eu volutpat id neque pellentesque">
content
</div>
))}
</div>
);
}
`,
output: `function Foo() {
return (
<div>
{foo?.data.map((_, index) => (
<div
key={index}
className="lorem ipsum dolor sit amet consectetur adipiscing elit proin ex massa hendrerit
eu posuere eu volutpat id neque pellentesque"
>
content
</div>
))}
</div>
);
}
`,
options: {
printWidth: 80,
Expand Down