Skip to content

Commit f988fb9

Browse files
committed
refactor(plugins/x): revert 'no-useless-fragment' and update its test cases
1 parent 7a654ff commit f988fb9

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ruleTester.run(RULE_NAME, rule, {
8181
errors: [{ type: AST_NODE_TYPES.JSXElement, messageId: "noUselessFragmentInBuiltIn" }],
8282
},
8383
{
84-
// whitepace tricky case
84+
// whitespace tricky case
8585
code: /* tsx */ `
8686
<section>
8787
git<>
@@ -161,6 +161,16 @@ ruleTester.run(RULE_NAME, rule, {
161161
"<Fooo content={<>eeee ee eeeeeee eeeeeeee</>} />",
162162
"<>{foos.map(foo => foo)}</>",
163163
"<>{moo}</>",
164+
/* tsx */ `
165+
function Foo() {
166+
return <>&nbsp;</>;
167+
}
168+
`,
169+
/* tsx */ `
170+
function Foo() {
171+
return <>a&nbsp;b</>;
172+
}
173+
`,
164174
/* tsx */ `
165175
<>
166176
{moo}
@@ -184,16 +194,6 @@ ruleTester.run(RULE_NAME, rule, {
184194
{moo}
185195
</>
186196
`,
187-
/* tsx */ `
188-
function Foo() {
189-
return <Bar><>&nbsp;</></Bar>;
190-
}
191-
`,
192-
/* tsx */ `
193-
function Foo() {
194-
return <Bar><>a&nbsp;b</></Bar>;
195-
}
196-
`,
197197
/* tsx */ `<>{cloneElement(children, { ref: childrenRef })}</>`,
198198
{
199199
code: /* tsx */ `

packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function check(
2424
if (JSX.isKeyedElement(node, initialScope)) return;
2525
if (JSX.isBuiltInElement(node.parent)) context.report({ messageId: "noUselessFragmentInBuiltIn", node });
2626
if (node.children.length === 0) return context.report({ messageId: "noUselessFragment", node });
27-
if (node.children.some((child) => JSX.isLiteral(child) && child.value !== child.raw)) return;
2827
const isChildren = AST.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent);
2928
const [firstChildren] = node.children;
3029
// <Foo content={<>ee eeee eeee ...</>} />

0 commit comments

Comments
 (0)