Skip to content

Commit

Permalink
undid editor prettifying opinions
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-nexudus committed Sep 18, 2018
1 parent eae31a0 commit 658379a
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions docs/rules/jsx-no-target-blank.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,44 @@ This rule aims to prevent user generated links from creating security vulnerabil

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
* `{"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

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

- enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
- enforce: optional string, defaults to "always"
* enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
* enforce: optional string, defaults to "always"


### always (default)

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

```jsx
var Hello = <a target="_blank" href="http://example.com/" />;
var Hello = <a target="_blank" href={dynamicLink} />;
var Hello = <a target='_blank' href="http://example.com/"></a>
var Hello = <a target='_blank' href={ dynamicLink }></a>
```

The following patterns are **not** considered errors:

```jsx
var Hello = <p target="_blank" />;
var Hello = (
<a target="_blank" rel="noopener noreferrer" href="http://example.com" />
);
var Hello = <a target="_blank" href="relative/path/in/the/host" />;
var Hello = <a target="_blank" href="/absolute/path/in/the/host" />;
var Hello = <a />;
var Hello = <p target='_blank'></p>
var Hello = <a target='_blank' rel='noopener noreferrer' href="http://example.com"></a>
var Hello = <a target='_blank' href="relative/path/in/the/host"></a>
var Hello = <a target='_blank' href="/absolute/path/in/the/host"></a>
var Hello = <a></a>
```

### never

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

```jsx
var Hello = <a target="_blank" href={dynamicLink} />;
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 658379a

Please sign in to comment.