gkiely / eslint-plugin-jsx-no-leaked-values

Prevent boolean expressions from adding unwanted falsy numbers to your JSX
MIT License
12 stars 0 forks source link

Allow for Boolean() #3

Open 4nduril-ms opened 9 months ago

4nduril-ms commented 9 months ago

Hi, I was just wondering if it would be possible to allow for Boolean calls on the left side of &&. I am not that much into ASTs and node types but I understand this would be a CallExpression. Can we somehow "see" what the resulting type of a call expression would be and mark it as a valid condition?

gkiely commented 9 months ago

@4nduril-ms calling Boolean(variable) does not show an error. E.g.

let x = 0;
const Component = () => {
  return <>{Boolean(x) && <div />}</>;
};

Can you provide a code sample that does?

4nduril-ms commented 9 months ago

That's weird.

Screenshot_20231214_121841

I will check if I can find any settings that are unusual. The project is rather complex (monorepo). But also, when I check out your repo and add the following test case to "valid" it fails:

    {
      code: `
      const Component = () => {
        return <>{Boolean(true) && <></>}</>;
      };
    `,
    },