logoESLint React
Rules

no-unsafe-target-blank

Disallows 'target="_blank"' without 'rel="noreferrer noopener"'.

Full Name in eslint-plugin-react-dom

react-dom/no-unsafe-target-blank

Full Name in @eslint-react/eslint-plugin

@eslint-react/dom-no-unsafe-target-blank

Features

🔧

Presets

strict strict-typescript strict-type-checked

Rule Details

When using target="_blank" on links without rel="noreferrer noopener", the opened page can access the window.opener property of the original page, which creates a security vulnerability known as tabnabbing.

Common Violations

Invalid

function MyComponent() {
  return (
    <a href="https://eslint-react.xyz" target="_blank">
      Example
    </a>
  );
}

Valid

function MyComponent() {
  return (
    <a href="https://eslint-react.xyz" target="_blank" rel="noreferrer noopener">
      Example
    </a>
  );
}

Resources

Further Reading


See Also

On this page