4
4
*/
5
5
"use strict"
6
6
7
- const RuleTester = require ( "eslint" ) . RuleTester
7
+ const { Linter , RuleTester } = require ( "eslint" )
8
8
const rule = require ( "../../../lib/rules/no-restricted-disable" )
9
+ const coreRules = new Linter ( ) . getRules ( )
9
10
const tester = new RuleTester ( )
10
11
12
+ tester . defineRule ( "foo/no-undef" , coreRules . get ( "no-undef" ) )
13
+ tester . defineRule ( "foo/no-redeclare" , coreRules . get ( "no-redeclare" ) )
14
+
11
15
tester . run ( "no-restricted-disable" , rule , {
12
16
valid : [
13
17
"/*eslint-disable*/" ,
14
18
"//eslint-disable-line" ,
15
19
"//eslint-disable-next-line" ,
16
20
{
17
- code : "/*eslint-disable b */" ,
18
- options : [ "a " ] ,
21
+ code : "/*eslint-disable eqeqeq */" ,
22
+ options : [ "no-unused-vars " ] ,
19
23
} ,
20
24
{
21
- code : "/*eslint-enable a */" ,
22
- options : [ "a " ] ,
25
+ code : "/*eslint-enable eqeqeq */" ,
26
+ options : [ "eqeqeq " ] ,
23
27
} ,
24
28
{
25
- code : "/*eslint-disable a */" ,
26
- options : [ "*" , "!a " ] ,
29
+ code : "/*eslint-disable eqeqeq */" ,
30
+ options : [ "*" , "!eqeqeq " ] ,
27
31
} ,
28
32
] ,
29
33
invalid : [
30
34
{
31
- code : "/*eslint-disable a */" ,
32
- options : [ "a " ] ,
33
- errors : [ "Disabling 'a ' is not allowed." ] ,
35
+ code : "/*eslint-disable eqeqeq */" ,
36
+ options : [ "eqeqeq " ] ,
37
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
34
38
} ,
35
39
{
36
40
code : "/*eslint-disable*/" ,
37
- options : [ "a " ] ,
38
- errors : [ "Disabling 'a ' is not allowed." ] ,
41
+ options : [ "eqeqeq " ] ,
42
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
39
43
} ,
40
44
{
41
- code : "//eslint-disable-line a " ,
42
- options : [ "a " ] ,
43
- errors : [ "Disabling 'a ' is not allowed." ] ,
45
+ code : "//eslint-disable-line eqeqeq " ,
46
+ options : [ "eqeqeq " ] ,
47
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
44
48
} ,
45
49
{
46
50
code : "//eslint-disable-line" ,
47
- options : [ "a " ] ,
48
- errors : [ "Disabling 'a ' is not allowed." ] ,
51
+ options : [ "eqeqeq " ] ,
52
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
49
53
} ,
50
54
{
51
- code : "//eslint-disable-next-line a " ,
52
- options : [ "a " ] ,
53
- errors : [ "Disabling 'a ' is not allowed." ] ,
55
+ code : "//eslint-disable-next-line eqeqeq " ,
56
+ options : [ "eqeqeq " ] ,
57
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
54
58
} ,
55
59
{
56
60
code : "//eslint-disable-next-line" ,
57
- options : [ "a " ] ,
58
- errors : [ "Disabling 'a ' is not allowed." ] ,
61
+ options : [ "eqeqeq " ] ,
62
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
59
63
} ,
60
64
61
65
{
62
- code : "/*eslint-disable a, b, c */" ,
63
- options : [ "*" , "!b " , "!c " ] ,
64
- errors : [ "Disabling 'a ' is not allowed." ] ,
66
+ code : "/*eslint-disable eqeqeq, no-undef, no-redeclare */" ,
67
+ options : [ "*" , "!no-undef " , "!no-redeclare " ] ,
68
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
65
69
} ,
66
70
{
67
71
code : "/*eslint-disable*/" ,
68
- options : [ "*" , "!b " , "!c " ] ,
69
- errors : [ "Disabling '*,!b,!c ' is not allowed." ] ,
72
+ options : [ "*" , "!no-undef " , "!no-redeclare " ] ,
73
+ errors : [ "Disabling '*,!no-undef,!no-redeclare ' is not allowed." ] ,
70
74
} ,
71
75
{
72
- code : "//eslint-disable-line a, b, c " ,
73
- options : [ "*" , "!b " , "!c " ] ,
74
- errors : [ "Disabling 'a ' is not allowed." ] ,
76
+ code : "//eslint-disable-line eqeqeq, no-undef, no-redeclare " ,
77
+ options : [ "*" , "!no-undef " , "!no-redeclare " ] ,
78
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
75
79
} ,
76
80
{
77
81
code : "//eslint-disable-line" ,
78
- options : [ "*" , "!b " , "!c " ] ,
79
- errors : [ "Disabling '*,!b,!c ' is not allowed." ] ,
82
+ options : [ "*" , "!no-undef " , "!no-redeclare " ] ,
83
+ errors : [ "Disabling '*,!no-undef,!no-redeclare ' is not allowed." ] ,
80
84
} ,
81
85
{
82
- code : "//eslint-disable-next-line a, b, c " ,
83
- options : [ "*" , "!b " , "!c " ] ,
84
- errors : [ "Disabling 'a ' is not allowed." ] ,
86
+ code : "//eslint-disable-next-line eqeqeq, no-undef, no-redeclare " ,
87
+ options : [ "*" , "!no-undef " , "!no-redeclare " ] ,
88
+ errors : [ "Disabling 'eqeqeq ' is not allowed." ] ,
85
89
} ,
86
90
{
87
91
code : "//eslint-disable-next-line" ,
88
- options : [ "*" , "!b " , "!c " ] ,
89
- errors : [ "Disabling '*,!b,!c ' is not allowed." ] ,
92
+ options : [ "*" , "!no-undef " , "!no-redeclare " ] ,
93
+ errors : [ "Disabling '*,!no-undef,!no-redeclare ' is not allowed." ] ,
90
94
} ,
91
95
92
96
{
@@ -100,11 +104,12 @@ tester.run("no-restricted-disable", rule, {
100
104
] ,
101
105
} ,
102
106
{
103
- code : "/*eslint-disable a, b, react/a, react/b*/" ,
104
- options : [ "react/*" ] ,
107
+ code :
108
+ "/*eslint-disable no-undef, no-redeclare, foo/no-undef, foo/no-redeclare*/" ,
109
+ options : [ "foo/*" ] ,
105
110
errors : [
106
- "Disabling 'react/a ' is not allowed." ,
107
- "Disabling 'react/b ' is not allowed." ,
111
+ "Disabling 'foo/no-undef ' is not allowed." ,
112
+ "Disabling 'foo/no-redeclare ' is not allowed." ,
108
113
] ,
109
114
} ,
110
115
] ,
0 commit comments