Skip to content

Commit f268cef

Browse files
committed
Remove schema changes to linkComponents
1 parent afb717c commit f268cef

File tree

3 files changed

+6
-66
lines changed

3 files changed

+6
-66
lines changed

docs/rules/jsx-no-target-blank.md

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ This rule aims to prevent user generated links from creating security vulnerabil
1414
## Rule Options
1515
```json
1616
...
17-
"react/jsx-no-target-blank": [<enabled>, { "enforceDynamicLinks": <enforce>, "components": [<string>|<object>] }]
17+
"react/jsx-no-target-blank": [<enabled>, { "enforceDynamicLinks": <enforce> }]
1818
...
1919
```
2020

2121
* enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
2222
* enforce: optional string, 'always' or 'never'
23-
* components: optional array
23+
* Link components can be something other than an `<a>`, see [shared settings](https://github.com/yannickcr/eslint-plugin-react/blob/master/README.md#configuration) for `linkComponents` configuration)
2424

2525
### `enforceDynamicLinks`
2626

@@ -55,19 +55,9 @@ When {"enforceDynamicLinks": "never"} is set, the following patterns are **not**
5555
var Hello = <a target='_blank' href={ dynamicLink }></a>
5656
```
5757

58-
### `components`
58+
### Link components
5959

60-
An array specifying the names of additional components that should also be validated.
61-
Each array element can either be a string with the component name or object specifying the name and url attribute:
62-
63-
When using an object like so:
64-
65-
```js
66-
{
67-
"name": "Link",
68-
"linkAttribute": "to"
69-
}
70-
```
60+
Link components can be something other than an `<a>`, see [shared settings](https://github.com/yannickcr/eslint-plugin-react/blob/master/README.md#configuration) for `linkComponents` configuration)
7161

7262
The following patterns are considered errors:
7363

@@ -85,15 +75,6 @@ var Hello = <Link target='_blank' to="/absolute/path/in/the/host"></Link>
8575
var Hello = <Link />
8676
```
8777

88-
When you use a string such as `'Link'`, it's equivalent to:
89-
90-
```js
91-
{
92-
"name": "Link",
93-
"linkAttribute": "href"
94-
}
95-
```
96-
9778
## When Not To Use It
9879

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

lib/rules/jsx-no-target-blank.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,6 @@ module.exports = {
5656
properties: {
5757
enforceDynamicLinks: {
5858
enum: ['always', 'never']
59-
},
60-
components: {
61-
type: 'array',
62-
items: {
63-
oneOf: [{
64-
type: 'string'
65-
}, {
66-
type: 'object',
67-
properties: {
68-
name: {
69-
type: 'string',
70-
minLength: 1
71-
},
72-
linkAttribute: {
73-
type: 'string',
74-
minLength: 1
75-
}
76-
}
77-
}]
78-
},
79-
uniqueItems: true
8059
}
8160
},
8261
additionalProperties: false
@@ -86,9 +65,8 @@ module.exports = {
8665
create: function(context) {
8766
const configuration = context.options[0] || {};
8867
const enforceDynamicLinks = configuration.enforceDynamicLinks || 'always';
89-
const linkComponents = DEFAULTS.concat(context.settings.linkComponents || []);
9068

91-
const elements = new Map((linkComponents.concat(configuration.components || [])).map(value => {
69+
const elements = new Map((DEFAULTS.concat(context.settings.linkComponents || [])).map(value => {
9270
const name = typeof value === 'string' ? value : value.name;
9371
const linkAttribute = typeof value === 'string' ? 'href' : value.linkAttribute;
9472
return [name, linkAttribute];

tests/lib/rules/jsx-no-target-blank.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ ruleTester.run('jsx-no-target-blank', rule, {
4848
code: '<a target="_blank" href={ dynamicLink }></a>',
4949
options: [{enforceDynamicLinks: 'never'}]
5050
},
51-
{
52-
code: '<Link target="_blank" href={ dynamicLink }></Link>',
53-
options: [{enforceDynamicLinks: 'never', components: ['Link']}]
54-
},
55-
{
56-
code: '<Link target="_blank" to={ dynamicLink }></Link>',
57-
options: [{enforceDynamicLinks: 'never', components: [{name: 'Link', linkAttribute: 'to'}]}]
58-
},
5951
{
6052
code: '<Link target="_blank" href={ dynamicLink }></Link>',
6153
options: [{enforceDynamicLinks: 'never'}],
@@ -102,22 +94,11 @@ ruleTester.run('jsx-no-target-blank', rule, {
10294
options: [{enforceDynamicLinks: 'always'}],
10395
errors: defaultErrors
10496
}, {
105-
code: '<Link target="_blank" href={ dynamicLink }></Link>',
106-
options: [{enforceDynamicLinks: 'always', components: ['Link']}],
107-
errors: defaultErrors
108-
},
109-
{
110-
code: '<Link target="_blank" to={ dynamicLink }></Link>',
111-
options: [{enforceDynamicLinks: 'always', components: [{name: 'Link', linkAttribute: 'to'}]}],
112-
errors: defaultErrors
113-
},
114-
{
11597
code: '<Link target="_blank" href={ dynamicLink }></Link>',
11698
options: [{enforceDynamicLinks: 'always'}],
11799
settings: {linkComponents: ['Link']},
118100
errors: defaultErrors
119-
},
120-
{
101+
}, {
121102
code: '<Link target="_blank" to={ dynamicLink }></Link>',
122103
options: [{enforceDynamicLinks: 'always'}],
123104
settings: {linkComponents: {name: 'Link', linkAttribute: 'to'}},

0 commit comments

Comments
 (0)