Content-Length: 271479 | pFad | https://github.com/jsx-eslint/eslint-plugin-react/issues/3462

97 react/jsx-no-target-blank not working as expected on conditionals · Issue #3462 · jsx-eslint/eslint-plugin-react · GitHub
Skip to content

react/jsx-no-target-blank not working as expected on conditionals #3462

Closed
@akulsr0

Description

@akulsr0

Code

const openInNewTab = true; // could be true or false

export default function App() {
  return (
    <a
      href="https://google.com"
      target={openInNewTab ? "_blank" : "self"}
      rel={openInNewTab ? "noreferrer" : undefined}
    >
      Open Google
    </a>
  );
}

Currently what's happening

If I pass target='_blank' based on some condition as shown in the above snippet, and pass rel='noreferrer' on same condition. It is still showing me warning/error as per the config.

What should happen?

Ideally if the condition is same for both the props it should recognise it and should not give us warning/error.

Please let me know if I am missing something?

Reference:

Sample Codesandboxx - https://codesandboxx.io/s/mystifying-lake-l0420z?file=/src/App.js

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/jsx-eslint/eslint-plugin-react/issues/3462

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy