DocumentationRulesno-unsafe-target-blank

no-unsafe-target-blank

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

  • dom
  • recommended
  • recommended-typescript
  • recommended-type-checked

What it does

Prevents the use of target="_blank" without rel="noreferrer noopener".

Examples

Failing

import React from "react";
 
function Example() {
  return (
    <a href="https://example.com" target="_blank">
      Example
    </a>
  );
}

Passing

import React from "react";
 
function Example() {
  return (
    <a href="https://example.com" target="_blank" rel="noreferrer noopener">
      Example
    </a>
  );
}