Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member of object and object can be undefined #5

Closed
DrChrispoper opened this issue Dec 6, 2021 · 2 comments · Fixed by #6
Closed

Member of object and object can be undefined #5

DrChrispoper opened this issue Dec 6, 2021 · 2 comments · Fixed by #6

Comments

@DrChrispoper
Copy link

Thanks for the amazing plugin!

I have a use case, one that made us look into having a rule like this. That doesn't seem to be caught yet.

const profile: $Profile | undefined
...
<div>
  {profile?.viewCount && <h2>Hey</h2>}
</div>
@alexfoxy
Copy link

alexfoxy commented Dec 6, 2021

For reference here is a test which should throw an error:

    {
      code: [
        'const first = { foo: 0 };',
        "<App>{first?.foo && <Foo/>}</App>",
      ].join("\n"),
      errors: [{ messageId: "conditionErrorFalseyString" }],
      parserOptions: {
        ecmaFeatures: {
          jsx: true,
        },
      },
      output: [
        'const first = { foo: 0 };',
        "<App>{!!first?.foo && <Foo/>}</App>",
      ].join("\n"),
      filename: "react.tsx",
    },

@hluisson
Copy link
Owner

Thanks for reporting. This should be fixed in the latest release, 1.3.1, which has just been published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants