1
1
import {
2
2
convertVariableName ,
3
- IgnoreLeadingTrailingUnderscoreMsg ,
3
+ ConstRequiredForAllCapsMsg ,
4
4
ForbiddenLeadingTrailingIdentifierMsg ,
5
5
IgnoreLeadingTrailingIdentifierMsg ,
6
- ForbiddenPascalSnakeMsg ,
7
- ConstRequiredForAllCapsMsg ,
8
- IgnoreOnlyLeadingUnderscoreMsg ,
9
- IgnoreOnlyTrailingUnderscoreMsg ,
10
6
} from "../variable-name" ;
11
7
12
8
describe ( convertVariableName , ( ) => {
@@ -18,8 +14,15 @@ describe(convertVariableName, () => {
18
14
expect ( result ) . toEqual ( {
19
15
rules : [
20
16
{
21
- notices : [ IgnoreLeadingTrailingUnderscoreMsg ] ,
22
- ruleName : "camelcase" ,
17
+ ruleName : "@typescript-eslint/naming-convention" ,
18
+ rules : [
19
+ {
20
+ selector : "variable" ,
21
+ format : [ "camelCase" , "UPPER_CASE" ] ,
22
+ leadingUnderscore : "forbid" ,
23
+ trailingUnderscore : "forbid" ,
24
+ } ,
25
+ ] ,
23
26
} ,
24
27
{
25
28
notices : [ ForbiddenLeadingTrailingIdentifierMsg ] ,
@@ -35,16 +38,23 @@ describe(convertVariableName, () => {
35
38
} ) ;
36
39
} ) ;
37
40
38
- test ( "conversion with require-const-for-all-caps argument" , ( ) => {
41
+ test ( "conversion with require-const-for-all-caps argument without check-format argument " , ( ) => {
39
42
const result = convertVariableName ( {
40
43
ruleArguments : [ "require-const-for-all-caps" ] ,
41
44
} ) ;
42
45
43
46
expect ( result ) . toEqual ( {
44
47
rules : [
45
48
{
46
- notices : [ IgnoreLeadingTrailingUnderscoreMsg , ConstRequiredForAllCapsMsg ] ,
47
- ruleName : "camelcase" ,
49
+ ruleName : "@typescript-eslint/naming-convention" ,
50
+ rules : [
51
+ {
52
+ selector : "variable" ,
53
+ format : [ "camelCase" , "UPPER_CASE" ] ,
54
+ leadingUnderscore : "forbid" ,
55
+ trailingUnderscore : "forbid" ,
56
+ } ,
57
+ ] ,
48
58
} ,
49
59
{
50
60
notices : [ ForbiddenLeadingTrailingIdentifierMsg ] ,
@@ -60,16 +70,23 @@ describe(convertVariableName, () => {
60
70
} ) ;
61
71
} ) ;
62
72
63
- test ( "conversion with allow-pascal-case argument" , ( ) => {
73
+ test ( "conversion with allow-pascal-case argument without check-format argument " , ( ) => {
64
74
const result = convertVariableName ( {
65
75
ruleArguments : [ "allow-pascal-case" ] ,
66
76
} ) ;
67
77
68
78
expect ( result ) . toEqual ( {
69
79
rules : [
70
80
{
71
- notices : [ IgnoreLeadingTrailingUnderscoreMsg , ForbiddenPascalSnakeMsg ] ,
72
- ruleName : "camelcase" ,
81
+ ruleName : "@typescript-eslint/naming-convention" ,
82
+ rules : [
83
+ {
84
+ selector : "variable" ,
85
+ format : [ "camelCase" , "UPPER_CASE" ] ,
86
+ leadingUnderscore : "forbid" ,
87
+ trailingUnderscore : "forbid" ,
88
+ } ,
89
+ ] ,
73
90
} ,
74
91
{
75
92
notices : [ ForbiddenLeadingTrailingIdentifierMsg ] ,
@@ -85,16 +102,23 @@ describe(convertVariableName, () => {
85
102
} ) ;
86
103
} ) ;
87
104
88
- test ( "conversion with allow-snake-case argument" , ( ) => {
105
+ test ( "conversion with allow-snake-case argument without check-format argument " , ( ) => {
89
106
const result = convertVariableName ( {
90
107
ruleArguments : [ "allow-snake-case" ] ,
91
108
} ) ;
92
109
93
110
expect ( result ) . toEqual ( {
94
111
rules : [
95
112
{
96
- ruleName : "camelcase" ,
97
- notices : [ IgnoreLeadingTrailingUnderscoreMsg , ForbiddenPascalSnakeMsg ] ,
113
+ ruleName : "@typescript-eslint/naming-convention" ,
114
+ rules : [
115
+ {
116
+ selector : "variable" ,
117
+ format : [ "camelCase" , "UPPER_CASE" ] ,
118
+ leadingUnderscore : "forbid" ,
119
+ trailingUnderscore : "forbid" ,
120
+ } ,
121
+ ] ,
98
122
} ,
99
123
{
100
124
notices : [ ForbiddenLeadingTrailingIdentifierMsg ] ,
@@ -118,8 +142,15 @@ describe(convertVariableName, () => {
118
142
expect ( result ) . toEqual ( {
119
143
rules : [
120
144
{
121
- ruleName : "camelcase" ,
122
- notices : [ IgnoreLeadingTrailingUnderscoreMsg ] ,
145
+ ruleName : "@typescript-eslint/naming-convention" ,
146
+ rules : [
147
+ {
148
+ selector : "variable" ,
149
+ format : [ "camelCase" , "UPPER_CASE" ] ,
150
+ leadingUnderscore : "forbid" ,
151
+ trailingUnderscore : "forbid" ,
152
+ } ,
153
+ ] ,
123
154
} ,
124
155
{
125
156
ruleName : "no-underscore-dangle" ,
@@ -143,8 +174,15 @@ describe(convertVariableName, () => {
143
174
expect ( result ) . toEqual ( {
144
175
rules : [
145
176
{
146
- notices : [ IgnoreLeadingTrailingUnderscoreMsg ] ,
147
- ruleName : "camelcase" ,
177
+ ruleName : "@typescript-eslint/naming-convention" ,
178
+ rules : [
179
+ {
180
+ selector : "variable" ,
181
+ format : [ "camelCase" , "UPPER_CASE" ] ,
182
+ leadingUnderscore : "forbid" ,
183
+ trailingUnderscore : "forbid" ,
184
+ } ,
185
+ ] ,
148
186
} ,
149
187
{
150
188
notices : [ ForbiddenLeadingTrailingIdentifierMsg ] ,
@@ -168,8 +206,48 @@ describe(convertVariableName, () => {
168
206
expect ( result ) . toEqual ( {
169
207
rules : [
170
208
{
171
- notices : [ IgnoreLeadingTrailingUnderscoreMsg ] ,
172
- ruleName : "camelcase" ,
209
+ ruleName : "@typescript-eslint/naming-convention" ,
210
+ rules : [
211
+ {
212
+ selector : "variable" ,
213
+ format : [ "camelCase" , "UPPER_CASE" ] ,
214
+ leadingUnderscore : "forbid" ,
215
+ trailingUnderscore : "forbid" ,
216
+ } ,
217
+ ] ,
218
+ } ,
219
+ {
220
+ notices : [ ForbiddenLeadingTrailingIdentifierMsg ] ,
221
+ ruleName : "no-underscore-dangle" ,
222
+ } ,
223
+ {
224
+ ruleName : "id-blacklist" ,
225
+ } ,
226
+ {
227
+ ruleName : "id-match" ,
228
+ } ,
229
+ ] ,
230
+ } ) ;
231
+ } ) ;
232
+
233
+ test ( "conversion with require-const-for-all-caps argument and check-format argument" , ( ) => {
234
+ const result = convertVariableName ( {
235
+ ruleArguments : [ "check-format" , "require-const-for-all-caps" ] ,
236
+ } ) ;
237
+
238
+ expect ( result ) . toEqual ( {
239
+ rules : [
240
+ {
241
+ notices : [ ConstRequiredForAllCapsMsg ] ,
242
+ ruleName : "@typescript-eslint/naming-convention" ,
243
+ rules : [
244
+ {
245
+ selector : "variable" ,
246
+ format : [ "camelCase" , "UPPER_CASE" ] ,
247
+ leadingUnderscore : "forbid" ,
248
+ trailingUnderscore : "forbid" ,
249
+ } ,
250
+ ] ,
173
251
} ,
174
252
{
175
253
notices : [ ForbiddenLeadingTrailingIdentifierMsg ] ,
@@ -193,8 +271,15 @@ describe(convertVariableName, () => {
193
271
expect ( result ) . toEqual ( {
194
272
rules : [
195
273
{
196
- notices : [ IgnoreOnlyLeadingUnderscoreMsg ] ,
197
- ruleName : "camelcase" ,
274
+ ruleName : "@typescript-eslint/naming-convention" ,
275
+ rules : [
276
+ {
277
+ selector : "variable" ,
278
+ format : [ "camelCase" , "UPPER_CASE" ] ,
279
+ leadingUnderscore : "allow" ,
280
+ trailingUnderscore : "forbid" ,
281
+ } ,
282
+ ] ,
198
283
} ,
199
284
{
200
285
notices : [ IgnoreLeadingTrailingIdentifierMsg ] ,
@@ -219,8 +304,15 @@ describe(convertVariableName, () => {
219
304
expect ( result ) . toEqual ( {
220
305
rules : [
221
306
{
222
- notices : [ IgnoreOnlyTrailingUnderscoreMsg ] ,
223
- ruleName : "camelcase" ,
307
+ ruleName : "@typescript-eslint/naming-convention" ,
308
+ rules : [
309
+ {
310
+ selector : "variable" ,
311
+ format : [ "camelCase" , "UPPER_CASE" ] ,
312
+ leadingUnderscore : "forbid" ,
313
+ trailingUnderscore : "allow" ,
314
+ } ,
315
+ ] ,
224
316
} ,
225
317
{
226
318
notices : [ IgnoreLeadingTrailingIdentifierMsg ] ,
@@ -249,8 +341,15 @@ describe(convertVariableName, () => {
249
341
expect ( result ) . toEqual ( {
250
342
rules : [
251
343
{
252
- notices : [ ] ,
253
- ruleName : "camelcase" ,
344
+ ruleName : "@typescript-eslint/naming-convention" ,
345
+ rules : [
346
+ {
347
+ selector : "variable" ,
348
+ format : [ "camelCase" , "UPPER_CASE" ] ,
349
+ leadingUnderscore : "allow" ,
350
+ trailingUnderscore : "allow" ,
351
+ } ,
352
+ ] ,
254
353
} ,
255
354
{
256
355
notices : [ IgnoreLeadingTrailingIdentifierMsg ] ,
@@ -283,8 +382,16 @@ describe(convertVariableName, () => {
283
382
expect ( result ) . toEqual ( {
284
383
rules : [
285
384
{
286
- ruleName : "camelcase" ,
287
- notices : [ ConstRequiredForAllCapsMsg , ForbiddenPascalSnakeMsg ] ,
385
+ ruleName : "@typescript-eslint/naming-convention" ,
386
+ rules : [
387
+ {
388
+ selector : "variable" ,
389
+ format : [ "camelCase" , "UPPER_CASE" ] ,
390
+ leadingUnderscore : "allow" ,
391
+ trailingUnderscore : "allow" ,
392
+ } ,
393
+ ] ,
394
+ notices : [ ConstRequiredForAllCapsMsg ] ,
288
395
} ,
289
396
{
290
397
ruleName : "no-underscore-dangle" ,
0 commit comments