Skip to content

Commit 237b055

Browse files
authored
fix(plugins/x): 'no-leaked-conditional-rendering' report empty string, closes #853 (#857)
1 parent 36e03e9 commit 237b055

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"eslint-import-resolver-oxc": "^0.4.0",
7979
"eslint-plugin-better-mutation": "^1.5.0",
8080
"eslint-plugin-eslint-comments": "^3.2.0",
81-
"eslint-plugin-eslint-plugin": "^6.3.1",
81+
"eslint-plugin-eslint-plugin": "^6.3.2",
8282
"eslint-plugin-import-x": "^4.4.2",
8383
"eslint-plugin-jsdoc": "^50.5.0",
8484
"eslint-plugin-perfectionist": "^3.9.1",

packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.spec.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@ import rule, { RULE_NAME } from "./no-leaked-conditional-rendering";
33

44
ruleTesterWithTypes.run(RULE_NAME, rule, {
55
invalid: [
6+
{
7+
code: /* tsx */ `
8+
/// <reference types="react" />
9+
/// <reference types="react-dom" />
10+
11+
const a = <>{"" && <Something />}</>;
12+
`,
13+
errors: [
14+
{ messageId: "noLeakedConditionalRendering" },
15+
],
16+
},
17+
{
18+
code: /* tsx */ `
19+
/// <reference types="react" />
20+
/// <reference types="react-dom" />
21+
22+
const someString = "";
23+
const a = <>{someString && <Something />}</>;
24+
`,
25+
errors: [
26+
{ messageId: "noLeakedConditionalRendering" },
27+
],
28+
},
629
{
730
code: /* tsx */ `
831
/// <reference types="react" />
@@ -400,7 +423,7 @@ ruleTesterWithTypes.run(RULE_NAME, rule, {
400423
401424
const a = <>
402425
{0 ? <Foo /> : null}
403-
{'' && <Foo />}
426+
{'0' && <Foo />}
404427
{NaN ? <Foo /> : null}
405428
</>
406429
`,

packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const allowedVariants = [
5555
"nullish",
5656
"object",
5757
"string",
58-
"falsy string",
5958
"falsy boolean",
6059
"truthy bigint",
6160
"truthy boolean",

pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)