Skip to content

Commit

Permalink
Merge pull request #1988 from atomcorp/master
Browse files Browse the repository at this point in the history
Add full example in react/jsx-no-target-blank
  • Loading branch information
ljharb committed Sep 20, 2018
2 parents a93080e + ac78b51 commit eb69dc5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions docs/rules/jsx-no-target-blank.md
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

0 comments on commit eb69dc5

Please sign in to comment.