@alfalab/stylelint-core-vars 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.test.js DELETED
@@ -1,861 +0,0 @@
1
- const vars = require('./utils').vars;
2
- const mixins = require('./utils').mixins;
3
- const {
4
- RULE_USE_VARS,
5
- RULE_USE_ONE_OF_VARS,
6
- RULE_USE_MIXINS,
7
- RULE_USE_ONE_OF_MIXINS,
8
- RULE_DO_NOT_USE_DARK_COLORS,
9
- RULE_DO_NOT_USE_OLD_VARS,
10
- messages,
11
- } = require('.');
12
-
13
- testRule({
14
- plugins: [RULE_USE_VARS],
15
- ruleName: RULE_USE_VARS,
16
- config: true,
17
- fix: true,
18
- accept: [
19
- {
20
- code: `.class {
21
- padding-left: var(--gap-2xs);
22
- }`,
23
- description: 'singleline rule with single value',
24
- },
25
- {
26
- code: `.class {
27
- /* stylelint-disable-next-line */
28
- padding-left: 8px;
29
- }`,
30
- description: 'singleline rule with single value',
31
- },
32
- {
33
- code: `.class {
34
- padding: var(--gap-xs) 0 var(--gap-m) 0;
35
- }`,
36
- description: 'singleline rule with multiple values',
37
- },
38
- {
39
- code: `.class {
40
- margin-top: var(--gap-xs);
41
- margin-bottom: var(--gap-l);
42
- }`,
43
- description: 'multiline rule',
44
- },
45
- {
46
- code: `.class {
47
- padding: var(--gap-xs) 0 var(--gap-m) 0;
48
- margin: var(--gap-l);
49
- }`,
50
- description: 'multiline rule',
51
- },
52
- {
53
- code: `.class {
54
- .inner {
55
- padding: var(--gap-xs) 0 var(--gap-m) 0;
56
- margin: var(--gap-l);
57
- }
58
- }`,
59
- description: 'nested rule',
60
- },
61
- {
62
- code: `.class {
63
- padding-left: 3px;
64
- color: #000;
65
- }`,
66
- description: 'custom value',
67
- },
68
- {
69
- code: `.class {
70
- box-shadow: 0 0 8px #B000B5, 0 0 8px #BADA55,
71
- 0 4px 8px #C0FFEE;
72
- }`,
73
- description: 'singleline rule with multiline value',
74
- },
75
- {
76
- code: `.class {
77
- background-color: var(--color-light-bg-primary);
78
- background: var(--color-light-bg-primary);
79
- color: var(--color-light-text-primary);
80
- }`,
81
- description: 'colors',
82
- },
83
- {
84
- code: `.class {
85
- border-radius: var(--border-radius-s);
86
- border-radius: var(--border-radius-m);
87
- border-radius: var(--border-radius-l);
88
- border-radius: var(--border-radius-xl);
89
- border-radius: var(--border-radius-circle);
90
- border-radius: var(--border-radius-pill);
91
- border-top-left-radius: var(--border-radius-s);
92
- border-top-right-radius: var(--border-radius-s);
93
- border-bottom-left-radius: var(--border-radius-s);
94
- border-bottom-right-radius: var(--border-radius-s);
95
- }`,
96
- description: 'border-radius',
97
- },
98
- {
99
- code: `.class {
100
- background-color: #fff;
101
- background: #fff;
102
- border: 1px solid #0b1f35;
103
- }`,
104
- description: 'not exact match',
105
- },
106
- ],
107
- reject: [
108
- {
109
- code: `.class {\n padding-top: 8px;\n}`,
110
- fixed: `.class {\n padding-top: var(--gap-xs);\n}`,
111
- description: 'hardcode single gap',
112
- message: messages[RULE_USE_VARS].expected(['--gap-xs'], '8px'),
113
- line: 2,
114
- column: 18,
115
- },
116
- {
117
- code: `.class {\n padding: 8px 12px 4px 16px;\n}`,
118
- fixed: `.class {\n padding: var(--gap-xs) var(--gap-s) var(--gap-2xs) var(--gap-m);\n}`,
119
- description: 'hardcode multiple gaps',
120
- warnings: [
121
- {
122
- message: messages[RULE_USE_VARS].expected(['--gap-2xs'], '4px'),
123
- line: 2,
124
- column: 23,
125
- },
126
- {
127
- message: messages[RULE_USE_VARS].expected(['--gap-xs'], '8px'),
128
- line: 2,
129
- column: 14,
130
- },
131
- {
132
- message: messages[RULE_USE_VARS].expected(['--gap-s'], '12px'),
133
- line: 2,
134
- column: 18,
135
- },
136
- {
137
- message: messages[RULE_USE_VARS].expected(['--gap-m'], '16px'),
138
- line: 2,
139
- column: 27,
140
- },
141
- ],
142
- },
143
- {
144
- code: `.class {
145
- .inner {
146
- padding: 8px 12px 4px 16px;
147
- }
148
- }`,
149
- fixed: `.class {
150
- .inner {
151
- padding: var(--gap-xs) var(--gap-s) var(--gap-2xs) var(--gap-m);
152
- }
153
- }`,
154
- description: 'hardcode nested rule',
155
- warnings: [
156
- {
157
- message: messages[RULE_USE_VARS].expected(['--gap-2xs'], '4px'),
158
- line: 3,
159
- column: 39,
160
- },
161
- {
162
- message: messages[RULE_USE_VARS].expected(['--gap-xs'], '8px'),
163
- line: 3,
164
- column: 30,
165
- },
166
- {
167
- message: messages[RULE_USE_VARS].expected(['--gap-s'], '12px'),
168
- line: 3,
169
- column: 34,
170
- },
171
- {
172
- message: messages[RULE_USE_VARS].expected(['--gap-m'], '16px'),
173
- line: 3,
174
- column: 43,
175
- },
176
- ],
177
- },
178
- {
179
- code: `.class {\n box-shadow: 0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04);\n}`,
180
- fixed: `.class {\n box-shadow: var(--shadow-xs);\n}`,
181
- description: 'hardcode singleline shadow',
182
- message: messages[RULE_USE_VARS].expected(
183
- ['--shadow-xs'],
184
- '0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04)'
185
- ),
186
- line: 2,
187
- column: 17,
188
- },
189
- {
190
- code: `.class {\n box-shadow: 0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04),
191
- 0 2px 4px rgba(11, 31, 53, 0.16);\n}`,
192
- fixed: `.class {\n box-shadow: var(--shadow-xs-hard);\n}`,
193
- description: 'hardcode multiline shadow',
194
- message: messages[RULE_USE_VARS].expected(
195
- ['--shadow-xs-hard'],
196
- '0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04), 0 2px 4px rgba(11, 31, 53, 0.16)'
197
- ),
198
- line: 2,
199
- column: 17,
200
- },
201
- {
202
- code: `.class {\n color: #0b1f35;\n}`,
203
- fixed: `.class {\n color: var(--color-light-text-primary);\n}`,
204
- description: 'hardcode single color',
205
- message: messages[RULE_USE_VARS].expected(['--color-light-text-primary'], '#0b1f35'),
206
- line: 2,
207
- column: 12,
208
- },
209
- {
210
- code: `.class {\n padding-top: 8px;\n box-shadow: 0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04);\n}`,
211
- fixed: `.class {\n padding-top: var(--gap-xs);\n box-shadow: var(--shadow-xs);\n}`,
212
- description: 'hardcode multiple props',
213
- warnings: [
214
- {
215
- message: messages[RULE_USE_VARS].expected(['--gap-xs'], '8px'),
216
- line: 2,
217
- column: 18,
218
- },
219
- {
220
- message: messages[RULE_USE_VARS].expected(
221
- ['--shadow-xs'],
222
- '0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04)'
223
- ),
224
- line: 3,
225
- column: 17,
226
- },
227
- ],
228
- },
229
- {
230
- code: `.class {\n border-radius: 8px;\n border-top-left-radius: 4px;\n}`,
231
- fixed: `.class {\n border-radius: var(--border-radius-m);\n border-top-left-radius: var(--border-radius-s);\n}`,
232
- description: 'hardcode border-radius',
233
- warnings: [
234
- {
235
- message: messages[RULE_USE_VARS].expected(['--border-radius-m'], '8px'),
236
- line: 2,
237
- column: 20,
238
- },
239
- {
240
- message: messages[RULE_USE_VARS].expected(['--border-radius-s'], '4px'),
241
- line: 3,
242
- column: 29,
243
- },
244
- ],
245
- },
246
- ...Object.entries(vars.gaps).map(([value, vars]) => {
247
- const gapVar = vars[0];
248
-
249
- const props = [
250
- 'padding',
251
- 'margin',
252
- 'padding-left',
253
- 'padding-right',
254
- 'padding-top',
255
- 'padding-bottom',
256
- 'margin-left',
257
- 'margin-right',
258
- 'margin-top',
259
- 'margin-bottom',
260
- ];
261
-
262
- return {
263
- code: `.class {
264
- ${props.map((prop) => `${prop}: ${value};`).join('\n')}
265
- }`,
266
- fixed: `.class {
267
- ${props.map((prop) => `${prop}: var(${gapVar});`).join('\n')}
268
- }`,
269
- description: `should use ${gapVar}`,
270
- warnings: props.map((_) => ({
271
- message: messages[RULE_USE_VARS].expected([gapVar], value),
272
- })),
273
- };
274
- }),
275
- ...Object.entries(vars.shadows).map(([value, vars]) => {
276
- const shadowVar = vars[0];
277
-
278
- return {
279
- code: `.class {
280
- box-shadow: ${value};
281
- }`,
282
- fixed: `.class {
283
- box-shadow: var(${shadowVar});
284
- }`,
285
- description: `should use ${shadowVar}`,
286
- message: messages[RULE_USE_VARS].expected([shadowVar], value),
287
- };
288
- }),
289
- ],
290
- });
291
-
292
- testRule({
293
- plugins: [RULE_USE_VARS],
294
- ruleName: RULE_USE_VARS,
295
- config: [true, { allowNumericValues: true }],
296
- fix: true,
297
- accept: [
298
- {
299
- code: `.class {
300
- padding-left: 4px;
301
- }`,
302
- description: 'singleline rule with single value',
303
- },
304
- {
305
- code: `.class {
306
- padding: 8px 0 16px 0;
307
- }`,
308
- description: 'singleline rule with multiple values',
309
- },
310
- {
311
- code: `.class {
312
- padding: 8px 0 16px 0;
313
- margin: var(--gap-l);
314
- }`,
315
- description: 'multiline rule',
316
- },
317
- {
318
- code: `.class {
319
- .inner {
320
- padding: 8px 0 16px 0;
321
- }
322
- }`,
323
- description: 'nested rule',
324
- },
325
- ],
326
- reject: [],
327
- });
328
-
329
- testRule({
330
- plugins: [RULE_USE_ONE_OF_VARS],
331
- ruleName: RULE_USE_ONE_OF_VARS,
332
- config: true,
333
- fix: true,
334
- accept: [
335
- {
336
- code: `.class {
337
- padding-left: var(--gap-2xs);
338
- }`,
339
- description: 'singleline rule with single value',
340
- },
341
- {
342
- code: `.class {
343
- padding: var(--gap-xs) 0 var(--gap-m) 0;
344
- }`,
345
- description: 'singleline rule with multiple values',
346
- },
347
- {
348
- code: `.class {
349
- margin-top: var(--gap-xs);
350
- margin-bottom: var(--gap-l);
351
- }`,
352
- description: 'multiline rule',
353
- },
354
- {
355
- code: `.class {
356
- padding: var(--gap-xs) 0 var(--gap-m) 0;
357
- margin: var(--gap-l);
358
- }`,
359
- description: 'multiline rule',
360
- },
361
- {
362
- code: `.class {
363
- .inner {
364
- padding: var(--gap-xs) 0 var(--gap-m) 0;
365
- margin: var(--gap-l);
366
- }
367
- }`,
368
- description: 'multiline nested rule',
369
- },
370
- {
371
- code: `.class {
372
- padding-left: 3px;
373
- color: #000;
374
- }`,
375
- description: 'custom value',
376
- },
377
- {
378
- code: `.class {
379
- box-shadow: 0 0 8px #B000B5, 0 0 8px #BADA55,
380
- 0 4px 8px #C0FFEE;
381
- }`,
382
- description: 'singleline rule with multiline value',
383
- },
384
- {
385
- code: `.class {
386
- background-color: var(--color-light-bg-primary);
387
- background: var(--color-light-bg-primary);
388
- color: var(--color-light-text-primary);
389
- }`,
390
- description: 'colors',
391
- },
392
- {
393
- code: `.class {
394
- border-radius: var(--border-radius-s);
395
- border-radius: var(--border-radius-m);
396
- border-radius: var(--border-radius-l);
397
- border-radius: var(--border-radius-xl);
398
- border-radius: var(--border-radius-circle);
399
- border-radius: var(--border-radius-pill);
400
- border-top-left-radius: var(--border-radius-s);
401
- border-top-right-radius: var(--border-radius-s);
402
- border-bottom-left-radius: var(--border-radius-s);
403
- border-bottom-right-radius: var(--border-radius-s);
404
- }`,
405
- description: 'border-radius',
406
- },
407
- ],
408
- reject: [
409
- {
410
- code: `.class {
411
- background-color: #fff;
412
- background: #fff;
413
- border: 1px solid #0b1f35;
414
- }`,
415
- fixed: `.class {
416
- background-color: #fff;
417
- background: #fff;
418
- border: 1px solid #0b1f35;
419
- }`,
420
- unfixable: true,
421
- description: 'hardcode colors',
422
- warnings: [
423
- {
424
- column: 35,
425
- line: 2,
426
- message: messages[RULE_USE_ONE_OF_VARS].expected(
427
- [
428
- '--color-light-bg-primary',
429
- '--color-light-specialbg-secondary-grouped',
430
- '--color-light-graphic-primary-inverted',
431
- ],
432
- '#fff'
433
- ),
434
- },
435
- {
436
- column: 29,
437
- line: 3,
438
- message: messages[RULE_USE_ONE_OF_VARS].expected(
439
- [
440
- '--color-light-bg-primary',
441
- '--color-light-specialbg-secondary-grouped',
442
- '--color-light-graphic-primary-inverted',
443
- ],
444
- '#fff'
445
- ),
446
- },
447
- {
448
- column: 35,
449
- line: 4,
450
- message: messages[RULE_USE_ONE_OF_VARS].expected(
451
- [
452
- '--color-light-border-key',
453
- '--color-light-graphic-primary',
454
- '--color-light-bg-primary-inverted',
455
- ],
456
- '#0b1f35'
457
- ),
458
- },
459
- ],
460
- },
461
- {
462
- code: `.class {
463
- .inner {
464
- background-color: #fff;
465
- background: #fff;
466
- border: 1px solid #0b1f35;
467
- }
468
- }`,
469
- fixed: `.class {
470
- .inner {
471
- background-color: #fff;
472
- background: #fff;
473
- border: 1px solid #0b1f35;
474
- }
475
- }`,
476
- unfixable: true,
477
- description: 'hardcode colors in nested rule',
478
- warnings: [
479
- {
480
- column: 39,
481
- line: 3,
482
- message: messages[RULE_USE_ONE_OF_VARS].expected(
483
- [
484
- '--color-light-bg-primary',
485
- '--color-light-specialbg-secondary-grouped',
486
- '--color-light-graphic-primary-inverted',
487
- ],
488
- '#fff'
489
- ),
490
- },
491
- {
492
- column: 33,
493
- line: 4,
494
- message: messages[RULE_USE_ONE_OF_VARS].expected(
495
- [
496
- '--color-light-bg-primary',
497
- '--color-light-specialbg-secondary-grouped',
498
- '--color-light-graphic-primary-inverted',
499
- ],
500
- '#fff'
501
- ),
502
- },
503
- {
504
- column: 39,
505
- line: 5,
506
- message: messages[RULE_USE_ONE_OF_VARS].expected(
507
- [
508
- '--color-light-border-key',
509
- '--color-light-graphic-primary',
510
- '--color-light-bg-primary-inverted',
511
- ],
512
- '#0b1f35'
513
- ),
514
- },
515
- ],
516
- },
517
- ],
518
- });
519
-
520
- testRule({
521
- plugins: [RULE_DO_NOT_USE_OLD_VARS],
522
- ruleName: RULE_DO_NOT_USE_OLD_VARS,
523
- config: true,
524
- fix: true,
525
- accept: [
526
- {
527
- code: `.class {
528
- color: #000;
529
- }`,
530
- description: 'custom value',
531
- },
532
- {
533
- code: `.class {
534
- background-color: var(--color-light-bg-primary);
535
- background: var(--color-light-bg-primary);
536
- color: var(--color-light-text-primary);
537
- }`,
538
- description: 'colors',
539
- },
540
- ],
541
- reject: [
542
- {
543
- code: `.class {\n background-color: var(--color-dark-indigo-10-flat);\n}`,
544
- fixed: `.class {\n background-color: var(--color-light-bg-tertiary);\n}`,
545
- message: messages[RULE_DO_NOT_USE_OLD_VARS].expected(
546
- ['--color-light-bg-tertiary'],
547
- '--color-dark-indigo-10-flat'
548
- ),
549
- line: 2,
550
- column: 27,
551
- },
552
- {
553
- code: `.class {\n background-color: var(--color-red-brand-85);\n}`,
554
- fixed: `.class {\n background-color: var(--color-red-brand-85);\n}`,
555
- unfixable: true,
556
- message: messages[RULE_DO_NOT_USE_OLD_VARS].expected([], ['--color-red-brand-85']),
557
- line: 2,
558
- column: 27,
559
- },
560
- {
561
- code: `.class {
562
- color: var(--color-red-brand-10-flat);
563
- background: var(--color-red-dark);
564
- fill: var(---color-black-10);
565
- }`,
566
- fixed: `.class {
567
- color: var(--color-red-brand-10-flat);
568
- background: var(--color-light-graphic-negative);
569
- fill: var(---color-black-10);
570
- }`,
571
- description: 'multiple variants',
572
- warnings: [
573
- {
574
- column: 28,
575
- line: 2,
576
- message: messages[RULE_DO_NOT_USE_OLD_VARS].expected(
577
- ['--color-light-bg-negative-muted'],
578
- '--color-red-brand-10-flat',
579
- false
580
- ),
581
- },
582
- {
583
- column: 33,
584
- line: 3,
585
- message: messages[RULE_DO_NOT_USE_OLD_VARS].expected(
586
- ['--color-light-graphic-negative'],
587
- '--color-red-dark',
588
- true
589
- ),
590
- },
591
- ],
592
- },
593
- ],
594
- });
595
-
596
- testRule({
597
- plugins: [RULE_USE_MIXINS],
598
- ruleName: RULE_USE_MIXINS,
599
- config: true,
600
- fix: true,
601
- accept: [
602
- {
603
- code: `.class {
604
- @mixin headline_xlarge;
605
- }`,
606
- description: 'typography',
607
- },
608
- {
609
- code: `.class {
610
- font-size: 14px;
611
- }`,
612
- description: 'not exact match',
613
- },
614
- {
615
- code: `.class {
616
- .inner {
617
- @mixin headline_xlarge;
618
- }
619
- }`,
620
- description: 'typography nested rule',
621
- },
622
- {
623
- code: `
624
- /* stylelint-disable ${RULE_USE_MIXINS} */
625
- .class {
626
- background-color: var(--color-light-bg-primary);
627
- font-size: 48px;
628
- line-height: 64px;
629
- background: var(--color-light-bg-primary);
630
- font-weight: 500;
631
- color: var(--color-light-text-primary);
632
- }
633
- /* stylelint-enable ${RULE_USE_MIXINS} */
634
- `,
635
- description: 'typography',
636
- },
637
- ],
638
- reject: [
639
- {
640
- code: `.class {
641
- background-color: var(--color-light-bg-primary);
642
- font-size: 48px;
643
- line-height: 64px;
644
- background: var(--color-light-bg-primary);
645
- font-weight: 500;
646
- color: var(--color-light-text-primary);
647
- }`,
648
- fixed: `.class {
649
- @mixin headline_xlarge;
650
- background-color: var(--color-light-bg-primary);
651
- background: var(--color-light-bg-primary);
652
- color: var(--color-light-text-primary);
653
- }`,
654
- description: 'typography',
655
- message: messages[RULE_USE_MIXINS].expected([{ name: 'headline_xlarge' }]),
656
- line: 3,
657
- column: 17,
658
- },
659
- {
660
- code: `.class {
661
- font-size: 48px;
662
- line-height: 64px;
663
- font-weight: 500;
664
- }`,
665
- fixed: `.class {
666
- @mixin headline_xlarge;
667
- }`,
668
- description: 'typography',
669
- message: messages[RULE_USE_MIXINS].expected([{ name: 'headline_xlarge' }]),
670
- line: 2,
671
- column: 17,
672
- },
673
- {
674
- code: `.class {
675
- font-size: 14px;
676
- line-height: 20px;
677
- font-weight: 400;
678
- }`,
679
- fixed: `.class {
680
- @mixin paragraph_primary_small;
681
- }`,
682
- description: 'typography',
683
- message: messages[RULE_USE_MIXINS].expected([{ name: 'paragraph_primary_small' }]),
684
- line: 2,
685
- column: 17,
686
- },
687
- {
688
- code: `.class {
689
- .inner {
690
- font-size: 48px;
691
- line-height: 64px;
692
- font-weight: 500;
693
- }
694
- }`,
695
- fixed: `.class {
696
- .inner {
697
- @mixin headline_xlarge;
698
- }
699
- }`,
700
- description: 'typography nested rule',
701
- message: messages[RULE_USE_MIXINS].expected([{ name: 'headline_xlarge' }]),
702
- line: 3,
703
- column: 21,
704
- },
705
- ],
706
- });
707
-
708
- testRule({
709
- plugins: [RULE_USE_ONE_OF_MIXINS],
710
- ruleName: RULE_USE_ONE_OF_MIXINS,
711
- config: true,
712
- fix: true,
713
- accept: [
714
- {
715
- code: `.class {
716
- @mixin headline_xlarge;
717
- }`,
718
- description: 'typography',
719
- },
720
- ],
721
- reject: [
722
- {
723
- code: `.class {
724
- font-size: 14px;
725
- line-height: 20px;
726
- }`,
727
- fixed: `.class {
728
- font-size: 14px;
729
- line-height: 20px;
730
- }`,
731
- unfixable: true,
732
- description: 'typography',
733
- message: messages[RULE_USE_ONE_OF_MIXINS].expected([
734
- {
735
- name: 'paragraph_primary_small',
736
- props: mixins.typography['paragraph_primary_small'],
737
- },
738
- { name: 'accent_primary_small', props: mixins.typography['accent_primary_small'] },
739
- { name: 'action_primary_small', props: mixins.typography['action_primary_small'] },
740
- ]),
741
- line: 2,
742
- column: 17,
743
- },
744
- {
745
- code: `.class {
746
- font-size: 14px;
747
- }`,
748
- fixed: `.class {
749
- font-size: 14px;
750
- }`,
751
- unfixable: true,
752
- description: 'typography',
753
- message: messages[RULE_USE_ONE_OF_MIXINS].expected([
754
- {
755
- name: 'paragraph_primary_small',
756
- props: mixins.typography['paragraph_primary_small'],
757
- },
758
- {
759
- name: 'paragraph_component_secondary',
760
- props: mixins.typography['paragraph_component_secondary'],
761
- },
762
- { name: 'accent_primary_small', props: mixins.typography['accent_primary_small'] },
763
- {
764
- name: 'accent_component_secondary',
765
- props: mixins.typography['accent_component_secondary'],
766
- },
767
- { name: 'action_primary_small', props: mixins.typography['action_primary_small'] },
768
- {
769
- name: 'action_component_secondary',
770
- props: mixins.typography['action_component_secondary'],
771
- },
772
- ]),
773
- line: 2,
774
- column: 17,
775
- },
776
- {
777
- code: `.class {
778
- .inner {
779
- font-size: 14px;
780
- }
781
- }`,
782
- fixed: `.class {
783
- .inner {
784
- font-size: 14px;
785
- }
786
- }`,
787
- unfixable: true,
788
- description: 'typography nested rule',
789
- message: messages[RULE_USE_ONE_OF_MIXINS].expected([
790
- {
791
- name: 'paragraph_primary_small',
792
- props: mixins.typography['paragraph_primary_small'],
793
- },
794
- {
795
- name: 'paragraph_component_secondary',
796
- props: mixins.typography['paragraph_component_secondary'],
797
- },
798
- { name: 'accent_primary_small', props: mixins.typography['accent_primary_small'] },
799
- {
800
- name: 'accent_component_secondary',
801
- props: mixins.typography['accent_component_secondary'],
802
- },
803
- { name: 'action_primary_small', props: mixins.typography['action_primary_small'] },
804
- {
805
- name: 'action_component_secondary',
806
- props: mixins.typography['action_component_secondary'],
807
- },
808
- ]),
809
- line: 3,
810
- column: 21,
811
- },
812
- ],
813
- });
814
-
815
- testRule({
816
- plugins: [RULE_DO_NOT_USE_DARK_COLORS],
817
- ruleName: RULE_DO_NOT_USE_DARK_COLORS,
818
- config: true,
819
- fix: true,
820
- accept: [
821
- {
822
- code: `.class {
823
- color: var(--color-light-text-primary);
824
- border: 1px solid var(--color-light-border-primary);
825
- }`,
826
- description: 'allowed colors',
827
- },
828
- {
829
- code: `.class {
830
- color: var(--color-dark-indigo);
831
- }`,
832
- description: 'old colors',
833
- },
834
- ],
835
- reject: [
836
- {
837
- code: `.class {
838
- color: var(--color-dark-text-primary);
839
- border: 1px solid var(--color-dark-border-primary);
840
- }`,
841
- fixed: `.class {
842
- color: var(--color-dark-text-primary);
843
- border: 1px solid var(--color-dark-border-primary);
844
- }`,
845
- unfixable: true,
846
- description: 'dark colors',
847
- warnings: [
848
- {
849
- column: 28,
850
- line: 2,
851
- message: messages[RULE_DO_NOT_USE_DARK_COLORS].expected(),
852
- },
853
- {
854
- column: 39,
855
- line: 3,
856
- message: messages[RULE_DO_NOT_USE_DARK_COLORS].expected(),
857
- },
858
- ],
859
- },
860
- ],
861
- });