Skip to content

Commit 3736e83

Browse files
author
Ken Earley
committed
DRY up error messages for js-no-target-blank test
1 parent 07f7e51 commit 3736e83

File tree

1 file changed

+14
-40
lines changed

1 file changed

+14
-40
lines changed

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

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const parserOptions = {
2525
// ------------------------------------------------------------------------------
2626

2727
const ruleTester = new RuleTester({parserOptions});
28+
const defaultErrors = [{
29+
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
30+
' see https://mathiasbynens.github.io/rel-noopener'
31+
}];
2832

2933
ruleTester.run('jsx-no-target-blank', rule, {
3034
valid: [
@@ -43,63 +47,33 @@ ruleTester.run('jsx-no-target-blank', rule, {
4347
],
4448
invalid: [{
4549
code: '<a target="_blank" href="http://example.com"></a>',
46-
errors: [{
47-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
48-
' see https://mathiasbynens.github.io/rel-noopener'
49-
}]
50+
errors: defaultErrors
5051
}, {
5152
code: '<a target="_blank" rel="" href="http://example.com"></a>',
52-
errors: [{
53-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
54-
' see https://mathiasbynens.github.io/rel-noopener'
55-
}]
53+
errors: defaultErrors
5654
}, {
5755
code: '<a target="_blank" rel="noopenernoreferrer" href="http://example.com"></a>',
58-
errors: [{
59-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
60-
' see https://mathiasbynens.github.io/rel-noopener'
61-
}]
56+
errors: defaultErrors
6257
}, {
6358
code: '<a target="_BLANK" href="http://example.com"></a>',
64-
errors: [{
65-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
66-
' see https://mathiasbynens.github.io/rel-noopener'
67-
}]
59+
errors: defaultErrors
6860
}, {
6961
code: '<a target="_blank" href="//example.com"></a>',
70-
errors: [{
71-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
72-
' see https://mathiasbynens.github.io/rel-noopener'
73-
}]
62+
errors: defaultErrors
7463
}, {
7564
code: '<a target="_blank" href="//example.com" rel={true}></a>',
76-
errors: [{
77-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
78-
' see https://mathiasbynens.github.io/rel-noopener'
79-
}]
65+
errors: defaultErrors
8066
}, {
8167
code: '<a target="_blank" href="//example.com" rel={3}></a>',
82-
errors: [{
83-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
84-
' see https://mathiasbynens.github.io/rel-noopener'
85-
}]
68+
errors: defaultErrors
8669
}, {
8770
code: '<a target="_blank" href="//example.com" rel={null}></a>',
88-
errors: [{
89-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
90-
' see https://mathiasbynens.github.io/rel-noopener'
91-
}]
71+
errors: defaultErrors
9272
}, {
9373
code: '<a target="_blank" href="//example.com" rel></a>',
94-
errors: [{
95-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
96-
' see https://mathiasbynens.github.io/rel-noopener'
97-
}]
74+
errors: defaultErrors
9875
}, {
9976
code: '<a target="_blank" href={ dynamicLink }></a>',
100-
errors: [{
101-
message: 'Using target="_blank" without rel="noopener noreferrer" is a security risk:' +
102-
' see https://mathiasbynens.github.io/rel-noopener'
103-
}]
77+
errors: defaultErrors
10478
}]
10579
});

0 commit comments

Comments
 (0)