Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions docs/rules/jsx-no-target-blank.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ This rule aims to prevent user generated links from creating security vulnerabil
`rel='noreferrer noopener'` for external links, and optionally any dynamically generated links.

## Rule Options
```json
...
"react/jsx-no-target-blank": [<enabled>, { "enforceDynamicLinks": <enforce> }]
...
```

There are two main options for the rule:

* `{"enforceDynamicLinks": "always"}` enforces the rule if the href is a dynamic link (default)
* `{"enforceDynamicLinks": "never"}` does not enforce the rule if the href is a dynamic link

* enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
* enforce: optional string, 'always' or 'never'

### always (default)
`{"enforceDynamicLinks": "always"}` enforces the rule if the href is a dynamic link (default)

When {"enforceDynamicLinks": "always"} is set, the following patterns are considered errors:

Expand All @@ -40,6 +43,8 @@ var Hello = <a></a>

### never

`{"enforceDynamicLinks": "never"}` does not enforce the rule if the href is a dynamic link

When {"enforceDynamicLinks": "never"} is set, the following patterns are **not** considered errors:

```jsx
Expand All @@ -48,4 +53,4 @@ var Hello = <a target='_blank' href={ dynamicLink }></a>

## When Not To Use It

If you do not have any external links, you can disable this rule
If you do not have any external links, you can disable this rule