Skip to content

Commit

Permalink
fix(plugins/x): 'no-leaked-conditional-rendering' report empty string,
Browse files Browse the repository at this point in the history
…closes #853 (#857)
  • Loading branch information
Rel1cx authored Nov 18, 2024
1 parent 36e03e9 commit 237b055
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"eslint-import-resolver-oxc": "^0.4.0",
"eslint-plugin-better-mutation": "^1.5.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-plugin": "^6.3.1",
"eslint-plugin-eslint-plugin": "^6.3.2",
"eslint-plugin-import-x": "^4.4.2",
"eslint-plugin-jsdoc": "^50.5.0",
"eslint-plugin-perfectionist": "^3.9.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ import rule, { RULE_NAME } from "./no-leaked-conditional-rendering";

ruleTesterWithTypes.run(RULE_NAME, rule, {
invalid: [
{
code: /* tsx */ `
/// <reference types="react" />
/// <reference types="react-dom" />
const a = <>{"" && <Something />}</>;
`,
errors: [
{ messageId: "noLeakedConditionalRendering" },
],
},
{
code: /* tsx */ `
/// <reference types="react" />
/// <reference types="react-dom" />
const someString = "";
const a = <>{someString && <Something />}</>;
`,
errors: [
{ messageId: "noLeakedConditionalRendering" },
],
},
{
code: /* tsx */ `
/// <reference types="react" />
Expand Down Expand Up @@ -400,7 +423,7 @@ ruleTesterWithTypes.run(RULE_NAME, rule, {
const a = <>
{0 ? <Foo /> : null}
{'' && <Foo />}
{'0' && <Foo />}
{NaN ? <Foo /> : null}
</>
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const allowedVariants = [
"nullish",
"object",
"string",
"falsy string",
"falsy boolean",
"truthy bigint",
"truthy boolean",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 237b055

Please sign in to comment.