@@ -24,18 +24,82 @@ const ruleTester = new RuleTester({
24
24
ruleTester . run ( "camelcase" , ruleCamelcase , {
25
25
valid : [
26
26
{
27
- code : "interface Foo { b_ar: null }" ,
27
+ code : "interface Foo { b_ar: number }" ,
28
28
options : [ { properties : "never" } ]
29
29
} ,
30
30
{
31
- code : "interface Foo { bar: null }" ,
31
+ code : "interface Foo { bar: number }" ,
32
+ options : [ { properties : "always" } ]
33
+ } ,
34
+ {
35
+ code : "class Foo { b_ar: number; }" ,
36
+ options : [ { properties : "never" } ]
37
+ } ,
38
+ {
39
+ code : "class Foo { bar: number; }" ,
40
+ options : [ { properties : "always" } ]
41
+ } ,
42
+ {
43
+ code : "class Foo { b_ar: number = 0; }" ,
44
+ options : [ { properties : "never" } ]
45
+ } ,
46
+ {
47
+ code : "class Foo { bar: number = 0; }" ,
48
+ options : [ { properties : "always" } ]
49
+ } ,
50
+ {
51
+ code : "class Foo { constructor(private b_ar: number) {} }" ,
52
+ options : [ { properties : "never" } ]
53
+ } ,
54
+ {
55
+ code : "class Foo { constructor(private bar: number) {} }" ,
56
+ options : [ { properties : "always" } ]
57
+ } ,
58
+ {
59
+ code : "class Foo { constructor(private b_ar: number = 0) {} }" ,
60
+ options : [ { properties : "never" } ]
61
+ } ,
62
+ {
63
+ code : "class Foo { constructor(private bar: number = 0) {} }" ,
64
+ options : [ { properties : "always" } ]
65
+ } ,
66
+ {
67
+ code : "abstract class Foo { b_ar: number; }" ,
68
+ options : [ { properties : "never" } ]
69
+ } ,
70
+ {
71
+ code : "abstract class Foo { bar: number; }" ,
72
+ options : [ { properties : "always" } ]
73
+ } ,
74
+ {
75
+ code : "abstract class Foo { b_ar: number = 0; }" ,
76
+ options : [ { properties : "never" } ]
77
+ } ,
78
+ {
79
+ code : "abstract class Foo { bar: number = 0; }" ,
80
+ options : [ { properties : "always" } ]
81
+ } ,
82
+ {
83
+ code : "abstract class Foo { abstract b_ar: number; }" ,
84
+ options : [ { properties : "never" } ]
85
+ } ,
86
+ {
87
+ code : "abstract class Foo { abstract bar: number; }" ,
88
+ options : [ { properties : "always" } ]
89
+ } ,
90
+ {
91
+ code : "abstract class Foo { abstract b_ar: number = 0; }" ,
92
+ options : [ { properties : "never" } ]
93
+ } ,
94
+ {
95
+ code : "abstract class Foo { abstract bar: number = 0; }" ,
32
96
options : [ { properties : "always" } ]
33
97
}
34
98
] ,
35
99
36
100
invalid : [
37
101
{
38
- code : "interface Foo { b_ar: null }" ,
102
+ code : "interface Foo { b_ar: number }" ,
39
103
options : [ { properties : "always" } ] ,
40
104
errors : [
41
105
{
@@ -44,6 +108,83 @@ ruleTester.run("camelcase", ruleCamelcase, {
44
108
column : 17
45
109
}
46
110
]
111
+ } ,
112
+ {
113
+ code : "class Foo { b_ar: number; }" ,
114
+ options : [ { properties : "always" } ] ,
115
+ errors : [
116
+ {
117
+ message : "Identifier 'b_ar' is not in camel case." ,
118
+ line : 1 ,
119
+ column : 13
120
+ }
121
+ ]
122
+ } ,
123
+ {
124
+ code : "class Foo { constructor(private b_ar: number) {} }" ,
125
+ options : [ { properties : "always" } ] ,
126
+ errors : [
127
+ {
128
+ message : "Identifier 'b_ar' is not in camel case." ,
129
+ line : 1 ,
130
+ column : 33
131
+ }
132
+ ]
133
+ } ,
134
+ {
135
+ code : "class Foo { constructor(private b_ar: number = 0) {} }" ,
136
+ options : [ { properties : "always" } ] ,
137
+ errors : [
138
+ {
139
+ message : "Identifier 'b_ar' is not in camel case." ,
140
+ line : 1 ,
141
+ column : 33
142
+ }
143
+ ]
144
+ } ,
145
+ {
146
+ code : "abstract class Foo { b_ar: number; }" ,
147
+ options : [ { properties : "always" } ] ,
148
+ errors : [
149
+ {
150
+ message : "Identifier 'b_ar' is not in camel case." ,
151
+ line : 1 ,
152
+ column : 22
153
+ }
154
+ ]
155
+ } ,
156
+ {
157
+ code : "abstract class Foo { b_ar: number = 0; }" ,
158
+ options : [ { properties : "always" } ] ,
159
+ errors : [
160
+ {
161
+ message : "Identifier 'b_ar' is not in camel case." ,
162
+ line : 1 ,
163
+ column : 22
164
+ }
165
+ ]
166
+ } ,
167
+ {
168
+ code : "abstract class Foo { abstract b_ar: number; }" ,
169
+ options : [ { properties : "always" } ] ,
170
+ errors : [
171
+ {
172
+ message : "Identifier 'b_ar' is not in camel case." ,
173
+ line : 1 ,
174
+ column : 31
175
+ }
176
+ ]
177
+ } ,
178
+ {
179
+ code : "abstract class Foo { abstract b_ar: number = 0; }" ,
180
+ options : [ { properties : "always" } ] ,
181
+ errors : [
182
+ {
183
+ message : "Identifier 'b_ar' is not in camel case." ,
184
+ line : 1 ,
185
+ column : 31
186
+ }
187
+ ]
47
188
}
48
189
]
49
190
} ) ;
0 commit comments