@primer/stylelint-config 13.0.0-rc.980b8d0 → 13.0.0-rc.d369892

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.
Files changed (3) hide show
  1. package/dist/index.cjs +1698 -0
  2. package/dist/index.mjs +1695 -0
  3. package/package.json +1 -1
package/dist/index.mjs ADDED
@@ -0,0 +1,1695 @@
1
+ import browsers from '@github/browserslist-config';
2
+ import stylelint from 'stylelint';
3
+ import anymatch from 'anymatch';
4
+ import valueParser from 'postcss-value-parser';
5
+ import TapMap from 'tap-map';
6
+ import variables from '@primer/css/dist/variables.json' assert { type: 'json' };
7
+ import declarationValueIndex from 'stylelint/lib/utils/declarationValueIndex.cjs';
8
+ import matchAll from 'string.prototype.matchall';
9
+ import { createRequire } from 'node:module';
10
+
11
+ var propertyOrder = [
12
+ 'all',
13
+ 'position',
14
+ 'top',
15
+ 'right',
16
+ 'bottom',
17
+ 'left',
18
+ 'z-index',
19
+ 'display',
20
+ 'float',
21
+ 'width',
22
+ 'min-width',
23
+ 'max-width',
24
+ 'height',
25
+ 'min-height',
26
+ 'max-height',
27
+ 'box-sizing',
28
+ 'padding',
29
+ 'padding-top',
30
+ 'padding-right',
31
+ 'padding-bottom',
32
+ 'padding-left',
33
+ 'margin',
34
+ 'margin-top',
35
+ 'margin-right',
36
+ 'margin-bottom',
37
+ 'margin-left',
38
+ 'overflow',
39
+ 'overflow-x',
40
+ 'overflow-y',
41
+ 'clip',
42
+ 'clear',
43
+ 'font',
44
+ 'font-family',
45
+ 'font-size',
46
+ 'font-style',
47
+ 'font-weight',
48
+ 'font-variant',
49
+ 'font-size-adjust',
50
+ 'font-stretch',
51
+ 'font-effect',
52
+ 'font-emphasize',
53
+ 'font-emphasize-position',
54
+ 'font-emphasize-style',
55
+ 'font-smooth',
56
+ 'hyphens',
57
+ 'line-height',
58
+ 'color',
59
+ 'text-align',
60
+ 'text-align-last',
61
+ 'text-emphasis',
62
+ 'text-emphasis-color',
63
+ 'text-emphasis-style',
64
+ 'text-emphasis-position',
65
+ 'text-decoration',
66
+ 'text-indent',
67
+ 'text-justify',
68
+ 'text-outline',
69
+ 'text-overflow',
70
+ 'text-overflow-ellipsis',
71
+ 'text-overflow-mode',
72
+ 'text-shadow',
73
+ 'text-transform',
74
+ 'text-wrap',
75
+ 'letter-spacing',
76
+ 'word-break',
77
+ 'word-spacing',
78
+ 'word-wrap',
79
+ 'tab-size',
80
+ 'white-space',
81
+ 'vertical-align',
82
+ 'list-style',
83
+ 'list-style-position',
84
+ 'list-style-type',
85
+ 'list-style-image',
86
+ 'pointer-events',
87
+ 'fill',
88
+ 'fill-opacity',
89
+ 'stroke',
90
+ 'stroke-opacity',
91
+ 'stroke-width',
92
+ 'shape-rendering',
93
+ 'cursor',
94
+ 'visibility',
95
+ 'zoom',
96
+ 'flex-direction',
97
+ 'flex-order',
98
+ 'flex-pack',
99
+ 'flex-align',
100
+ 'table-layout',
101
+ 'empty-cells',
102
+ 'caption-side',
103
+ 'border-spacing',
104
+ 'border-collapse',
105
+ 'content',
106
+ 'quotes',
107
+ 'counter-reset',
108
+ 'counter-increment',
109
+ 'resize',
110
+ 'user-select',
111
+ 'nav-index',
112
+ 'nav-up',
113
+ 'nav-right',
114
+ 'nav-down',
115
+ 'nav-left',
116
+ 'background',
117
+ 'background-color',
118
+ 'background-image',
119
+ 'filter',
120
+ 'background-repeat',
121
+ 'background-attachment',
122
+ 'background-position',
123
+ 'background-position-x',
124
+ 'background-position-y',
125
+ 'background-clip',
126
+ 'background-origin',
127
+ 'background-size',
128
+ 'border',
129
+ 'border-color',
130
+ 'border-style',
131
+ 'border-width',
132
+ 'border-top',
133
+ 'border-top-color',
134
+ 'border-top-style',
135
+ 'border-top-width',
136
+ 'border-right',
137
+ 'border-right-color',
138
+ 'border-right-style',
139
+ 'border-right-width',
140
+ 'border-bottom',
141
+ 'border-bottom-color',
142
+ 'border-bottom-style',
143
+ 'border-bottom-width',
144
+ 'border-left',
145
+ 'border-left-color',
146
+ 'border-left-style',
147
+ 'border-left-width',
148
+ 'border-radius',
149
+ 'border-top-left-radius',
150
+ 'border-top-right-radius',
151
+ 'border-bottom-right-radius',
152
+ 'border-bottom-left-radius',
153
+ 'border-image',
154
+ 'border-image-source',
155
+ 'border-image-slice',
156
+ 'border-image-width',
157
+ 'border-image-outset',
158
+ 'border-image-repeat',
159
+ 'outline',
160
+ 'outline-width',
161
+ 'outline-style',
162
+ 'outline-color',
163
+ 'outline-offset',
164
+ 'box-shadow',
165
+ 'opacity',
166
+ 'transition',
167
+ 'transition-delay',
168
+ 'transition-timing-function',
169
+ 'transition-duration',
170
+ 'transition-property',
171
+ 'transform',
172
+ 'transform-origin',
173
+ 'animation',
174
+ 'animation-name',
175
+ 'animation-duration',
176
+ 'animation-fill-mode',
177
+ 'animation-play-state',
178
+ 'animation-timing-function',
179
+ 'animation-delay',
180
+ 'animation-iteration-count',
181
+ 'animation-direction',
182
+ ];
183
+
184
+ const SKIP_VALUE_NODE_TYPES = new Set(['space', 'div']);
185
+ const SKIP_AT_RULE_NAMES = new Set(['each', 'for', 'function', 'mixin']);
186
+
187
+ function declarationValidator(rules, options = {}) {
188
+ const {formatMessage = defaultMessageFormatter, variables, verbose = false} = options;
189
+ const variableReplacements = new TapMap();
190
+ if (variables) {
191
+ for (const [name, {values}] of Object.entries(variables)) {
192
+ for (const value of values) {
193
+ variableReplacements.tap(value, () => []).push(name);
194
+ }
195
+ }
196
+ }
197
+
198
+ const validators = Object.entries(rules)
199
+ .map(([key, rule]) => {
200
+ if (rule === false) {
201
+ return false
202
+ }
203
+ const {name = key, props = name, expects = `a ${name} value`} = rule;
204
+ const replacements = Object.assign({}, rule.replacements, getVariableReplacements(rule.values));
205
+ // console.warn(`replacements for "${key}": ${JSON.stringify(replacements)}`)
206
+ Object.assign(rule, {name, props, expects, replacements});
207
+ return {
208
+ rule,
209
+ matchesProp: anymatch(props),
210
+ validate: Array.isArray(rule.components) ? componentValidator(rule) : valueValidator(rule),
211
+ }
212
+ })
213
+ .filter(Boolean);
214
+
215
+ const validatorsByProp = new TapMap();
216
+ const validatorsByReplacementValue = new Map();
217
+ for (const validator of validators) {
218
+ for (const value of Object.keys(validator.rule.replacements)) {
219
+ validatorsByReplacementValue.set(value, validator);
220
+ }
221
+ }
222
+
223
+ return decl => {
224
+ if (closest(decl, isSkippableAtRule)) {
225
+ if (verbose) {
226
+ // eslint-disable-next-line no-console
227
+ console.warn(`skipping declaration: ${decl.parent.toString()}`);
228
+ }
229
+ // As a general rule, any rule nested in an at-rule is ignored, since
230
+ // @for, @each, @mixin, and @function blocks can use whatever variables
231
+ // they want
232
+ return {valid: true}
233
+ }
234
+ const validator = getPropValidator(decl.prop);
235
+ if (validator) {
236
+ const result = validator.validate(decl);
237
+ result.errors = result.errors.map(formatMessage);
238
+ return result
239
+ } else {
240
+ return {valid: true}
241
+ }
242
+ }
243
+
244
+ function getVariableReplacements(values) {
245
+ const replacements = {};
246
+ const varValues = (Array.isArray(values) ? values : [values]).filter(v => typeof v === 'string' && v.includes('$'));
247
+ const matches = anymatch(varValues);
248
+ for (const [value, aliases] of variableReplacements.entries()) {
249
+ for (const alias of aliases) {
250
+ if (matches(alias)) {
251
+ replacements[value] = alias;
252
+ }
253
+ }
254
+ }
255
+ return replacements
256
+ }
257
+
258
+ function getPropValidator(prop) {
259
+ return validatorsByProp.tap(prop, () => validators.find(v => v.matchesProp(prop)))
260
+ }
261
+
262
+ function valueValidator({expects, values, replacements, singular = false}) {
263
+ const matches = anymatch(values);
264
+ return function validate({prop, value}, nested) {
265
+ if (matches(value)) {
266
+ return {
267
+ valid: true,
268
+ errors: [],
269
+ fixable: false,
270
+ replacement: undefined,
271
+ }
272
+ } else if (replacements[value]) {
273
+ let replacement = value;
274
+ do {
275
+ replacement = replacements[replacement];
276
+ } while (replacements[replacement])
277
+ return {
278
+ valid: false,
279
+ errors: [{expects, prop, value, replacement}],
280
+ fixable: true,
281
+ replacement,
282
+ }
283
+ } else {
284
+ if (nested || singular) {
285
+ return {
286
+ valid: false,
287
+ errors: [{expects, prop, value}],
288
+ fixable: false,
289
+ replacement: undefined,
290
+ }
291
+ }
292
+
293
+ const parsed = valueParser(value);
294
+ const validations = parsed.nodes
295
+ .map((node, index) => Object.assign(node, {index}))
296
+ .filter(node => !SKIP_VALUE_NODE_TYPES.has(node.type))
297
+ .map(node => {
298
+ const validation = validate({prop, value: valueParser.stringify(node)}, true);
299
+ validation.index = node.index;
300
+ return validation
301
+ });
302
+
303
+ const valid = validations.every(v => v.valid);
304
+ if (valid) {
305
+ return {valid, errors: [], fixable: false, replacement: undefined}
306
+ }
307
+
308
+ const fixable = validations.some(v => v.fixable);
309
+ const errors = validations.reduce((list, v) => list.concat(v.errors), []);
310
+
311
+ let replacement = undefined;
312
+ for (const validation of validations) {
313
+ if (fixable && validation.replacement) {
314
+ parsed.nodes[validation.index] = {type: 'word', value: validation.replacement};
315
+ }
316
+ }
317
+
318
+ if (fixable) {
319
+ replacement = valueParser.stringify(parsed);
320
+ }
321
+
322
+ return {
323
+ valid,
324
+ fixable,
325
+ errors,
326
+ replacement,
327
+ }
328
+ }
329
+ }
330
+ }
331
+
332
+ function componentValidator({expects, components, values, replacements}) {
333
+ const matchesCompoundValue = anymatch(values);
334
+ return decl => {
335
+ const {prop, value: compoundValue} = decl;
336
+ const parsed = valueParser(compoundValue);
337
+ if (parsed.nodes.length === 1 && matchesCompoundValue(compoundValue)) {
338
+ return {valid: true, errors: []}
339
+ }
340
+
341
+ const errors = [];
342
+
343
+ let fixable = false;
344
+ let componentIndex = 0;
345
+ for (const [index, node] of Object.entries(parsed.nodes)) {
346
+ if (SKIP_VALUE_NODE_TYPES.has(node.type)) {
347
+ continue
348
+ }
349
+
350
+ const value = valueParser.stringify(node);
351
+
352
+ let componentProp = components[componentIndex++];
353
+ let validator = getPropValidator(componentProp);
354
+ if (validatorsByReplacementValue.has(value)) {
355
+ validator = validatorsByReplacementValue.get(value);
356
+ componentProp = validator.rule.name;
357
+ }
358
+
359
+ const nestedProp = `${componentProp} (in ${prop})`;
360
+ if (validator) {
361
+ const result = validator.validate({prop: nestedProp, value}, true);
362
+ if (result.replacement) {
363
+ parsed.nodes[index] = {
364
+ type: 'word',
365
+ value: result.replacement,
366
+ };
367
+ fixable = true;
368
+ }
369
+ for (const error of result.errors) {
370
+ errors.push(error);
371
+ }
372
+ } else {
373
+ errors.push({expects, prop: nestedProp, value});
374
+ }
375
+ }
376
+
377
+ let replacement = fixable ? valueParser.stringify(parsed) : undefined;
378
+
379
+ // if a compound replacement exists, suggest *that* instead
380
+ if (replacement && replacements[replacement]) {
381
+ do {
382
+ replacement = replacements[replacement];
383
+ } while (replacements[replacement])
384
+ return {
385
+ valid: false,
386
+ errors: [{expects, prop, value: compoundValue, replacement}],
387
+ fixable: true,
388
+ replacement,
389
+ }
390
+ }
391
+
392
+ return {
393
+ valid: errors.length === 0,
394
+ errors,
395
+ fixable,
396
+ replacement,
397
+ }
398
+ }
399
+ }
400
+
401
+ function isSkippableAtRule(node) {
402
+ return node.type === 'atrule' && SKIP_AT_RULE_NAMES.has(node.name)
403
+ }
404
+ }
405
+
406
+ function defaultMessageFormatter(error) {
407
+ const {expects, value, replacement} = error;
408
+ const expected = replacement ? `"${replacement}"` : expects;
409
+ return `Please use ${expected} instead of "${value}"`
410
+ }
411
+
412
+ function closest(node, test) {
413
+ let ancestor = node;
414
+ do {
415
+ if (test(ancestor)) return ancestor
416
+ } while ((ancestor = ancestor.parent))
417
+ }
418
+
419
+ function createVariableRule(ruleName, rules, url) {
420
+ const plugin = stylelint.createPlugin(ruleName, (enabled, options = {}, context) => {
421
+ if (enabled === false) {
422
+ return noop$4
423
+ }
424
+
425
+ let actualRules = rules;
426
+ let overrides = options.rules;
427
+ if (typeof rules === 'function') {
428
+ actualRules = rules({variables, options, ruleName});
429
+ } else {
430
+ actualRules = Object.assign({}, rules);
431
+ }
432
+ if (typeof overrides === 'function') {
433
+ delete options.rules;
434
+ overrides = overrides({rules: actualRules, options, ruleName, variables});
435
+ }
436
+ if (overrides) {
437
+ Object.assign(actualRules, overrides);
438
+ }
439
+ const validate = declarationValidator(actualRules, {variables});
440
+
441
+ // The stylelint docs suggest respecting a "disableFix" rule option that
442
+ // overrides the "global" context.fix (--fix) linting option.
443
+ const {verbose = false, disableFix} = options;
444
+ const fixEnabled = context && context.fix && !disableFix;
445
+ const seen = new WeakMap();
446
+
447
+ return (root, result) => {
448
+ root.walkRules(rule => {
449
+ rule.walkDecls(decl => {
450
+ if (seen.has(decl)) {
451
+ return
452
+ } else {
453
+ seen.set(decl, true);
454
+ }
455
+
456
+ const validated = validate(decl);
457
+ const {valid, fixable, replacement, errors} = validated;
458
+ if (valid) {
459
+ // eslint-disable-next-line no-console
460
+ if (verbose) console.warn(`valid: "${decl.toString()}" in: "${rule.selector}"`);
461
+ return
462
+ } else if (fixEnabled && fixable) {
463
+ // eslint-disable-next-line no-console
464
+ if (verbose) console.warn(` fixed: ${replacement}`);
465
+ decl.value = replacement;
466
+ } else {
467
+ // eslint-disable-next-line no-console
468
+ if (verbose) console.warn(` ${errors.length} error(s)`);
469
+ for (const error of errors) {
470
+ const message = stylelint.utils
471
+ .ruleMessages(ruleName, {
472
+ rejected: m => {
473
+ if (url) {
474
+ return `${m}. See ${url}.`
475
+ }
476
+ return `${m}.`
477
+ },
478
+ })
479
+ .rejected(error);
480
+
481
+ stylelint.utils.report({
482
+ message,
483
+ node: decl,
484
+ result,
485
+ ruleName,
486
+ });
487
+ }
488
+ }
489
+ });
490
+ });
491
+ }
492
+ });
493
+
494
+ Object.assign(plugin, {rules});
495
+
496
+ return plugin
497
+ }
498
+
499
+ function noop$4() {}
500
+
501
+ var borders = createVariableRule(
502
+ 'primer/borders',
503
+ {
504
+ border: {
505
+ expects: 'a border variable',
506
+ props: 'border{,-top,-right,-bottom,-left}',
507
+ values: ['$border', 'none', '0'],
508
+ components: ['border-width', 'border-style', 'border-color'],
509
+ replacements: {
510
+ // because shorthand border properties ¯\_(ツ)_/¯
511
+ '$border-width $border-style $border-gray': '$border',
512
+ '$border-width $border-gray $border-style': '$border',
513
+ '$border-style $border-width $border-gray': '$border',
514
+ '$border-style $border-gray $border-width': '$border',
515
+ '$border-gray $border-width $border-style': '$border',
516
+ '$border-gray $border-style $border-width': '$border',
517
+ '$border-width $border-style $border-color': '$border',
518
+ '$border-width $border-color $border-style': '$border',
519
+ '$border-style $border-width $border-color': '$border',
520
+ '$border-style $border-color $border-width': '$border',
521
+ '$border-color $border-width $border-style': '$border',
522
+ '$border-color $border-style $border-width': '$border',
523
+ },
524
+ },
525
+ 'border color': {
526
+ expects: 'a border color variable',
527
+ props: 'border{,-top,-right,-bottom,-left}-color',
528
+ values: [
529
+ '$border-*',
530
+ 'transparent',
531
+ 'currentColor',
532
+ // Match variables in any of the following formats: --color-border-*, --color-*-border-*, --color-*-border, --borderColor-, *borderColor*
533
+ /var\(--color-(.+-)*border(-.+)*\)/,
534
+ /var\(--color-[^)]+\)/,
535
+ /var\(--borderColor-[^)]+\)/,
536
+ /var\((.+-)*borderColor(-.+)*\)/,
537
+ ],
538
+ replacements: {
539
+ '$border-gray': '$border-color',
540
+ },
541
+ },
542
+ 'border style': {
543
+ expects: 'a border style variable',
544
+ props: 'border{,-top,-right,-bottom,-left}-style',
545
+ values: ['$border-style', 'none'],
546
+ },
547
+ 'border width': {
548
+ expects: 'a border width variable',
549
+ props: 'border{,-top,-right,-bottom,-left}-width',
550
+ values: ['$border-width*', '0'],
551
+ },
552
+ 'border radius': {
553
+ expects: 'a border radius variable',
554
+ props: 'border{,-{top,bottom}-{left,right}}-radius',
555
+ values: ['$border-radius', '0', '50%', 'inherit'],
556
+ replacements: {
557
+ '100%': '50%',
558
+ },
559
+ },
560
+ },
561
+ 'https://primer.style/css/utilities/borders',
562
+ );
563
+
564
+ var boxShadow = createVariableRule(
565
+ 'primer/box-shadow',
566
+ {
567
+ 'box shadow': {
568
+ expects: 'a box-shadow variable',
569
+ props: 'box-shadow',
570
+ values: [
571
+ '$box-shadow*',
572
+ '$*-shadow',
573
+ 'none',
574
+ // Match variables in any of the following formats: --color-shadow-*, --color-*-shadow-*, --color-*-shadow, --shadow-*, *shadow*
575
+ /var\(--color-(.+-)*shadow(-.+)*\)/,
576
+ /var\(--shadow(-.+)*\)/,
577
+ /var\((.+-)*shadow(-.+)*\)/,
578
+ ],
579
+ singular: true,
580
+ },
581
+ },
582
+ 'https://primer.style/css/utilities/box-shadow',
583
+ );
584
+
585
+ const bgVars = [
586
+ '$bg-*',
587
+ '$tooltip-background-color',
588
+ // Match variables in any of the following formats: --color-bg-*, --color-*-bg-*, --color-*-bg, *bgColor*, *fgColor*, *borderColor*, *iconColor*
589
+ /var\(--color-(.+-)*bg(-.+)*\)/,
590
+ /var\(--color-[^)]+\)/,
591
+ /var\((.+-)*bgColor(-.+)*\)/,
592
+ /var\((.+-)*fgColor(-.+)*\)/,
593
+ /var\((.+-)*borderColor(-.+)*\)/,
594
+ /var\((.+-)*iconColor(-.+)*\)/,
595
+ ];
596
+
597
+ var colors = createVariableRule(
598
+ 'primer/colors',
599
+ {
600
+ 'background-color': {
601
+ expects: 'a background color variable',
602
+ values: bgVars.concat('none', 'transparent'),
603
+ },
604
+ background: {
605
+ expects: 'a background color variable',
606
+ values: bgVars.concat('none', 'transparent', 'top', 'right', 'bottom', 'left', 'center', '*px', 'url(*)'),
607
+ },
608
+ 'text color': {
609
+ expects: 'a text color variable',
610
+ props: 'color',
611
+ values: [
612
+ '$text-*',
613
+ '$tooltip-text-color',
614
+ 'inherit',
615
+ // Match variables in any of the following formats: --color-text-*, --color-*-text-*, --color-*-text, *fgColor*, *iconColor*
616
+ /var\(--color-(.+-)*text(-.+)*\)/,
617
+ /var\(--color-(.+-)*fg(-.+)*\)/,
618
+ /var\(--color-[^)]+\)/,
619
+ /var\((.+-)*fgColor(-.+)*\)/,
620
+ /var\((.+-)*iconColor(-.+)*\)/,
621
+ ],
622
+ },
623
+ },
624
+ 'https://primer.style/primitives/colors',
625
+ );
626
+
627
+ const ruleName$3 = 'primer/responsive-widths';
628
+
629
+ const messages$3 = stylelint.utils.ruleMessages(ruleName$3, {
630
+ rejected: value => {
631
+ return `A value larger than the smallest viewport could break responsive pages. Use a width value smaller than ${value}. https://primer.style/css/support/breakpoints`
632
+ },
633
+ });
634
+
635
+ // 320px is the smallest viewport size that we support
636
+
637
+ const walkGroups$1 = (root, validate) => {
638
+ for (const node of root.nodes) {
639
+ if (node.type === 'function') {
640
+ walkGroups$1(node, validate);
641
+ } else {
642
+ validate(node);
643
+ }
644
+ }
645
+ return root
646
+ };
647
+
648
+ // eslint-disable-next-line no-unused-vars
649
+ var responsiveWidths = stylelint.createPlugin(ruleName$3, (enabled, options = {}, context) => {
650
+ if (!enabled) {
651
+ return noop$3
652
+ }
653
+
654
+ const lintResult = (root, result) => {
655
+ root.walk(decl => {
656
+ // Ignore things inside of breakpoints
657
+ if (decl.type === 'atrule' && decl.name === 'include' && decl.params.includes('breakpoint')) {
658
+ return false
659
+ }
660
+
661
+ if (decl.type !== 'decl' || !decl.prop.match(/^(min-width|width)/)) {
662
+ return noop$3
663
+ }
664
+
665
+ const problems = [];
666
+
667
+ walkGroups$1(valueParser(decl.value), node => {
668
+ // Only check word types. https://github.com/TrySound/postcss-value-parser#word
669
+ if (node.type !== 'word') {
670
+ return
671
+ }
672
+
673
+ // Exact values to ignore.
674
+ if (['*', '+', '-', '/', '0', 'auto', 'inherit', 'initial'].includes(node.value)) {
675
+ return
676
+ }
677
+
678
+ const valueUnit = valueParser.unit(node.value);
679
+
680
+ switch (valueUnit.unit) {
681
+ case 'px':
682
+ if (parseInt(valueUnit.number) > 320) {
683
+ problems.push({
684
+ index: declarationValueIndex(decl) + node.sourceIndex,
685
+ message: messages$3.rejected(node.value),
686
+ });
687
+ }
688
+ break
689
+ case 'vw':
690
+ if (parseInt(valueUnit.number) > 100) {
691
+ problems.push({
692
+ index: declarationValueIndex(decl) + node.sourceIndex,
693
+ message: messages$3.rejected(node.value),
694
+ });
695
+ }
696
+ break
697
+ }
698
+ });
699
+
700
+ if (problems.length) {
701
+ for (const err of problems) {
702
+ stylelint.utils.report({
703
+ index: err.index,
704
+ message: err.message,
705
+ node: decl,
706
+ result,
707
+ ruleName: ruleName$3,
708
+ });
709
+ }
710
+ }
711
+ });
712
+ };
713
+
714
+ return lintResult
715
+ });
716
+
717
+ function noop$3() {}
718
+
719
+ // TODO: Pull this in from primer/primitives
720
+ const spacerValues = {
721
+ '$spacer-1': '4px',
722
+ '$spacer-2': '8px',
723
+ '$spacer-3': '16px',
724
+ '$spacer-4': '24px',
725
+ '$spacer-5': '32px',
726
+ '$spacer-6': '40px',
727
+ '$spacer-7': '48px',
728
+ '$spacer-8': '64px',
729
+ '$spacer-9': '80px',
730
+ '$spacer-10': '96px',
731
+ '$spacer-11': '112px',
732
+ '$spacer-12': '128px',
733
+ '$em-spacer-1': '0.0625em',
734
+ '$em-spacer-2': '0.125em',
735
+ '$em-spacer-3': '0.25em',
736
+ '$em-spacer-4': '0.375em',
737
+ '$em-spacer-5': '0.5em',
738
+ '$em-spacer-6': '0.75em',
739
+ };
740
+
741
+ const ruleName$2 = 'primer/spacing';
742
+ const messages$2 = stylelint.utils.ruleMessages(ruleName$2, {
743
+ rejected: (value, replacement) => {
744
+ if (replacement === null) {
745
+ return `Please use a primer spacer variable instead of '${value}'. Consult the primer docs for a suitable replacement. https://primer.style/css/storybook/?path=/docs/support-spacing--docs`
746
+ }
747
+
748
+ return `Please replace ${value} with spacing variable '${replacement}'.`
749
+ },
750
+ });
751
+
752
+ const walkGroups = (root, validate) => {
753
+ for (const node of root.nodes) {
754
+ if (node.type === 'function') {
755
+ walkGroups(node, validate);
756
+ } else {
757
+ validate(node);
758
+ }
759
+ }
760
+ return root
761
+ };
762
+
763
+ // eslint-disable-next-line no-unused-vars
764
+ var spacing = stylelint.createPlugin(ruleName$2, (enabled, options = {}, context) => {
765
+ if (!enabled) {
766
+ return noop$2
767
+ }
768
+
769
+ const lintResult = (root, result) => {
770
+ root.walk(decl => {
771
+ if (decl.type !== 'decl' || !decl.prop.match(/^(padding|margin)/)) {
772
+ return noop$2
773
+ }
774
+
775
+ const problems = [];
776
+
777
+ const parsedValue = walkGroups(valueParser(decl.value), node => {
778
+ // Remove leading negative sign, if any.
779
+ const cleanValue = node.value.replace(/^-/g, '');
780
+
781
+ // Only check word types. https://github.com/TrySound/postcss-value-parser#word
782
+ if (node.type !== 'word') {
783
+ return
784
+ }
785
+
786
+ // Exact values to ignore.
787
+ if (['*', '+', '-', '/', '0', 'auto', 'inherit', 'initial'].includes(node.value)) {
788
+ return
789
+ }
790
+
791
+ const valueUnit = valueParser.unit(cleanValue);
792
+
793
+ if (valueUnit && (valueUnit.unit === '' || !/^[0-9.]+$/.test(valueUnit.number))) {
794
+ return
795
+ }
796
+
797
+ // If the a variable is found in the value, skip it.
798
+ if (
799
+ Object.keys(spacerValues).some(variable =>
800
+ new RegExp(`${variable.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(cleanValue),
801
+ )
802
+ ) {
803
+ return
804
+ }
805
+
806
+ const replacement = Object.keys(spacerValues).find(spacer => spacerValues[spacer] === cleanValue) || null;
807
+ const valueMatch = replacement ? spacerValues[replacement] : node.value;
808
+
809
+ if (replacement && context.fix) {
810
+ node.value = node.value.replace(valueMatch, replacement);
811
+ } else {
812
+ problems.push({
813
+ index: declarationValueIndex(decl) + node.sourceIndex,
814
+ message: messages$2.rejected(valueMatch, replacement),
815
+ });
816
+ }
817
+
818
+ return
819
+ });
820
+
821
+ if (context.fix) {
822
+ decl.value = parsedValue.toString();
823
+ }
824
+
825
+ if (problems.length) {
826
+ for (const err of problems) {
827
+ stylelint.utils.report({
828
+ index: err.index,
829
+ message: err.message,
830
+ node: decl,
831
+ result,
832
+ ruleName: ruleName$2,
833
+ });
834
+ }
835
+ }
836
+ });
837
+ };
838
+
839
+ return lintResult
840
+ });
841
+
842
+ function noop$2() {}
843
+
844
+ var typography = createVariableRule(
845
+ 'primer/typography',
846
+ {
847
+ 'font-size': {
848
+ expects: 'a font-size variable',
849
+ values: ['$body-font-size', '$h{000,00,0,1,2,3,4,5,6}-size', '$font-size-*', '1', '1em', 'inherit'],
850
+ },
851
+ 'font-weight': {
852
+ props: 'font-weight',
853
+ values: ['$font-weight-*', 'inherit'],
854
+ replacements: {
855
+ bold: '$font-weight-bold',
856
+ normal: '$font-weight-normal',
857
+ },
858
+ },
859
+ 'line-height': {
860
+ props: 'line-height',
861
+ values: ['$body-line-height', '$lh-*', '0', '1', '1em', 'inherit'],
862
+ },
863
+ },
864
+ 'https://primer.style/css/utilities/typography',
865
+ );
866
+
867
+ // Meant as temp until we can move to primitives or css
868
+ const colorTypes = ['accent', 'success', 'attention', 'severe', 'danger', 'open', 'closed', 'done', 'sponsors'];
869
+
870
+ var utilities$1 = {
871
+ color: [
872
+ {
873
+ value: 'var(--color-fg-default)',
874
+ utilityClass: 'color-fg-default',
875
+ },
876
+ {
877
+ value: 'var(--color-fg-muted)',
878
+ utilityClass: 'color-fg-muted',
879
+ },
880
+ {
881
+ value: 'var(--color-fg-subtle)',
882
+ utilityClass: 'color-fg-subtle',
883
+ },
884
+ ].concat(
885
+ colorTypes.map(type => {
886
+ return {
887
+ value: `var(--color-${type}-fg)`,
888
+ utilityClass: `color-fg-${type}`,
889
+ }
890
+ }),
891
+ ),
892
+ 'background-color': [
893
+ {
894
+ value: 'var(--color-canvas-default)',
895
+ utilityClass: 'color-bg-default',
896
+ },
897
+ {
898
+ value: 'var(--color-canvas-overlay)',
899
+ utilityClass: 'color-bg-overlay',
900
+ },
901
+ {
902
+ value: 'var(--color-canvas-inset)',
903
+ utilityClass: 'color-bg-inset',
904
+ },
905
+ {
906
+ value: 'var(--color-canvas-subtle)',
907
+ utilityClass: 'color-bg-subtle',
908
+ },
909
+ {
910
+ value: 'transparent',
911
+ utilityClass: 'color-bg-transparent',
912
+ },
913
+ ]
914
+ .concat(
915
+ colorTypes.map(type => {
916
+ return {
917
+ value: `var(--color-${type}-subtle)`,
918
+ utilityClass: `color-bg-${type}`,
919
+ }
920
+ }),
921
+ )
922
+ .concat(
923
+ colorTypes.map(type => {
924
+ return {
925
+ value: `var(--color-${type}-emphasis)`,
926
+ utilityClass: `color-bg-${type}-emphasis`,
927
+ }
928
+ }),
929
+ ),
930
+ 'border-color': [
931
+ {
932
+ value: 'var(--color-border-default',
933
+ utilityClass: 'color-border-default',
934
+ },
935
+ {
936
+ value: 'var(--color-border-muted',
937
+ utilityClass: 'color-border-muted',
938
+ },
939
+ {
940
+ value: 'var(--color-border-subtle',
941
+ utilityClass: 'color-border-subtle',
942
+ },
943
+ ]
944
+ .concat(
945
+ colorTypes.map(type => {
946
+ return {
947
+ value: `var(--color-${type}-muted)`,
948
+ utilityClass: `color-border-${type}`,
949
+ }
950
+ }),
951
+ )
952
+ .concat(
953
+ colorTypes.map(type => {
954
+ return {
955
+ value: `var(--color-${type}-emphasis)`,
956
+ utilityClass: `color-border-${type}-emphasis`,
957
+ }
958
+ }),
959
+ ),
960
+ margin: Array.from(new Array(6)).map((_, i) => {
961
+ return {
962
+ value: `$spacer-${i + 1}`,
963
+ utilityClass: `m-${i + 1}`,
964
+ }
965
+ }),
966
+ 'margin-top': Array.from(new Array(6)).map((_, i) => {
967
+ return {
968
+ value: `$spacer-${i + 1}`,
969
+ utilityClass: `mt-${i + 1}`,
970
+ }
971
+ }),
972
+ 'margin-right': Array.from(new Array(6)).map((_, i) => {
973
+ return {
974
+ value: `$spacer-${i + 1}`,
975
+ utilityClass: `mr-${i + 1}`,
976
+ }
977
+ }),
978
+ 'margin-bottom': Array.from(new Array(6)).map((_, i) => {
979
+ return {
980
+ value: `$spacer-${i + 1}`,
981
+ utilityClass: `mb-${i + 1}`,
982
+ }
983
+ }),
984
+ 'margin-left': Array.from(new Array(6)).map((_, i) => {
985
+ return {
986
+ value: `$spacer-${i + 1}`,
987
+ utilityClass: `ml-${i + 1}`,
988
+ }
989
+ }),
990
+ padding: Array.from(new Array(6)).map((_, i) => {
991
+ return {
992
+ value: `$spacer-${i + 1}`,
993
+ utilityClass: `p-${i + 1}`,
994
+ }
995
+ }),
996
+ 'padding-top': Array.from(new Array(6)).map((_, i) => {
997
+ return {
998
+ value: `$spacer-${i + 1}`,
999
+ utilityClass: `pt-${i + 1}`,
1000
+ }
1001
+ }),
1002
+ 'padding-right': Array.from(new Array(6)).map((_, i) => {
1003
+ return {
1004
+ value: `$spacer-${i + 1}`,
1005
+ utilityClass: `pr-${i + 1}`,
1006
+ }
1007
+ }),
1008
+ 'padding-bottom': Array.from(new Array(6)).map((_, i) => {
1009
+ return {
1010
+ value: `$spacer-${i + 1}`,
1011
+ utilityClass: `pb-${i + 1}`,
1012
+ }
1013
+ }),
1014
+ 'padding-left': Array.from(new Array(6)).map((_, i) => {
1015
+ return {
1016
+ value: `$spacer-${i + 1}`,
1017
+ utilityClass: `pl-${i + 1}`,
1018
+ }
1019
+ }),
1020
+ 'line-height': [
1021
+ {
1022
+ value: '$lh-condensed-ultra',
1023
+ utilityClass: 'lh-condensed-ultra',
1024
+ },
1025
+ {
1026
+ value: '$lh-condensed',
1027
+ utilityClass: 'lh-condensed',
1028
+ },
1029
+ {
1030
+ value: '$lh-default',
1031
+ utilityClass: 'lh-default',
1032
+ },
1033
+ {
1034
+ value: '0',
1035
+ utilityClass: 'lh-0',
1036
+ },
1037
+ ],
1038
+ 'text-align': [
1039
+ {
1040
+ value: 'left',
1041
+ utilityClass: 'text-left',
1042
+ },
1043
+ {
1044
+ value: 'right',
1045
+ utilityClass: 'text-right',
1046
+ },
1047
+ {
1048
+ value: 'center',
1049
+ utilityClass: 'text-center',
1050
+ },
1051
+ ],
1052
+ 'font-style': [
1053
+ {
1054
+ value: 'italic',
1055
+ utilityClass: 'text-italic',
1056
+ },
1057
+ ],
1058
+ 'text-transform': [
1059
+ {
1060
+ value: 'uppercase',
1061
+ utilityClass: 'text-uppercase',
1062
+ },
1063
+ ],
1064
+ 'text-decoration': [
1065
+ {
1066
+ value: 'underline',
1067
+ utilityClass: 'text-underline',
1068
+ },
1069
+ {
1070
+ value: 'none',
1071
+ utilityClass: 'no-underline',
1072
+ },
1073
+ ],
1074
+ 'white-space': [
1075
+ {
1076
+ value: 'nowrap',
1077
+ utilityClass: 'no-wrap',
1078
+ },
1079
+ {
1080
+ value: 'normal',
1081
+ utilityClass: 'ws-normal',
1082
+ },
1083
+ ],
1084
+ 'word-break': [
1085
+ {
1086
+ value: 'break-all',
1087
+ utilityClass: 'wb-break-all',
1088
+ },
1089
+ ],
1090
+ width: [
1091
+ {
1092
+ value: '100%',
1093
+ utilityClass: 'width-full',
1094
+ },
1095
+ {
1096
+ value: 'auto%',
1097
+ utilityClass: 'width-auto',
1098
+ },
1099
+ ],
1100
+ overflow: [
1101
+ {
1102
+ value: 'visible',
1103
+ utilityClass: 'overflow-visible',
1104
+ },
1105
+ {
1106
+ value: 'hidden',
1107
+ utilityClass: 'overflow-hidden',
1108
+ },
1109
+ {
1110
+ value: 'auto',
1111
+ utilityClass: 'overflow-auto',
1112
+ },
1113
+ {
1114
+ value: 'scroll',
1115
+ utilityClass: 'overflow-scroll',
1116
+ },
1117
+ ],
1118
+ 'overflow-x': [
1119
+ {
1120
+ value: 'visible',
1121
+ utilityClass: 'overflow-x-visible',
1122
+ },
1123
+ {
1124
+ value: 'hidden',
1125
+ utilityClass: 'overflow-x-hidden',
1126
+ },
1127
+ {
1128
+ value: 'auto',
1129
+ utilityClass: 'overflow-x-auto',
1130
+ },
1131
+ {
1132
+ value: 'scroll',
1133
+ utilityClass: 'overflow-x-scroll',
1134
+ },
1135
+ ],
1136
+ 'overflow-y': [
1137
+ {
1138
+ value: 'visible',
1139
+ utilityClass: 'overflow-y-visible',
1140
+ },
1141
+ {
1142
+ value: 'hidden',
1143
+ utilityClass: 'overflow-y-hidden',
1144
+ },
1145
+ {
1146
+ value: 'auto',
1147
+ utilityClass: 'overflow-y-auto',
1148
+ },
1149
+ {
1150
+ value: 'scroll',
1151
+ utilityClass: 'overflow-y-scroll',
1152
+ },
1153
+ ],
1154
+ height: [
1155
+ {
1156
+ value: '100%',
1157
+ utilityClass: 'height-full',
1158
+ },
1159
+ ],
1160
+ 'max-width': [
1161
+ {
1162
+ value: '100%',
1163
+ utilityClass: 'width-fit',
1164
+ },
1165
+ ],
1166
+ 'max-height': [
1167
+ {
1168
+ value: '100%',
1169
+ utilityClass: 'height-fit',
1170
+ },
1171
+ ],
1172
+ 'min-width': [
1173
+ {
1174
+ value: '0',
1175
+ utilityClass: 'min-width-0',
1176
+ },
1177
+ ],
1178
+ float: [
1179
+ {
1180
+ value: 'left',
1181
+ utilityClass: 'float-left',
1182
+ },
1183
+ {
1184
+ value: 'right',
1185
+ utilityClass: 'float-right',
1186
+ },
1187
+ {
1188
+ value: 'none',
1189
+ utilityClass: 'float-none',
1190
+ },
1191
+ ],
1192
+ 'list-style': [
1193
+ {
1194
+ value: 'none',
1195
+ utilityClass: 'list-style-none',
1196
+ },
1197
+ ],
1198
+ 'user-select': [
1199
+ {
1200
+ value: 'none',
1201
+ utilityClass: 'user-select-none',
1202
+ },
1203
+ ],
1204
+ visibility: [
1205
+ {
1206
+ value: 'hidden',
1207
+ utilityClass: 'v-hidden',
1208
+ },
1209
+ {
1210
+ value: 'visible',
1211
+ utilityClass: 'v-visible',
1212
+ },
1213
+ ],
1214
+ 'vertical-align': [
1215
+ {
1216
+ value: 'middle',
1217
+ utilityClass: 'v-align-middle',
1218
+ },
1219
+ {
1220
+ value: 'top',
1221
+ utilityClass: 'v-align-top',
1222
+ },
1223
+ {
1224
+ value: 'bottom',
1225
+ utilityClass: 'v-align-bottom',
1226
+ },
1227
+ {
1228
+ value: 'text-top',
1229
+ utilityClass: 'v-align-text-top',
1230
+ },
1231
+ {
1232
+ value: 'text-bottom',
1233
+ utilityClass: 'v-align-text-bottom',
1234
+ },
1235
+ {
1236
+ value: 'text-baseline',
1237
+ utilityClass: 'v-align-baseline',
1238
+ },
1239
+ ],
1240
+ 'font-weight': [
1241
+ {
1242
+ value: '$font-weight-normal',
1243
+ utilityClass: 'text-normal',
1244
+ },
1245
+ {
1246
+ value: '$font-weight-bold',
1247
+ utilityClass: 'text-bold',
1248
+ },
1249
+ {
1250
+ value: '$font-weight-semibold',
1251
+ utilityClass: 'text-semibold',
1252
+ },
1253
+ {
1254
+ value: '$font-weight-light',
1255
+ utilityClass: 'text-light',
1256
+ },
1257
+ ],
1258
+ top: [
1259
+ {
1260
+ value: '0',
1261
+ utilityClass: 'top-0',
1262
+ },
1263
+ {
1264
+ value: 'auto',
1265
+ utilityClass: 'top-auto',
1266
+ },
1267
+ ],
1268
+ right: [
1269
+ {
1270
+ value: '0',
1271
+ utilityClass: 'right-0',
1272
+ },
1273
+ {
1274
+ value: 'auto',
1275
+ utilityClass: 'right-auto',
1276
+ },
1277
+ ],
1278
+ bottom: [
1279
+ {
1280
+ value: '0',
1281
+ utilityClass: 'bottom-0',
1282
+ },
1283
+ {
1284
+ value: 'auto',
1285
+ utilityClass: 'bottom-auto',
1286
+ },
1287
+ ],
1288
+ left: [
1289
+ {
1290
+ value: '0',
1291
+ utilityClass: 'left-0',
1292
+ },
1293
+ {
1294
+ value: 'auto',
1295
+ utilityClass: 'left-auto',
1296
+ },
1297
+ ],
1298
+ position: [
1299
+ {
1300
+ value: 'static',
1301
+ utilityClass: 'position-static',
1302
+ },
1303
+ {
1304
+ value: 'relative',
1305
+ utilityClass: 'position-relative',
1306
+ },
1307
+ {
1308
+ value: 'absolute',
1309
+ utilityClass: 'position-absolute',
1310
+ },
1311
+ {
1312
+ value: 'fixed',
1313
+ utilityClass: 'position-fixed',
1314
+ },
1315
+ {
1316
+ value: 'sticky',
1317
+ utilityClass: 'position-sticky',
1318
+ },
1319
+ ],
1320
+ 'box-shadow': [
1321
+ {
1322
+ value: 'none',
1323
+ utilityClass: 'box-shadow-none',
1324
+ },
1325
+ {
1326
+ value: 'var(--color-shadow-small)',
1327
+ utilityClass: 'box-shadow-small',
1328
+ },
1329
+ {
1330
+ value: 'var(--color-shadow-medium)',
1331
+ utilityClass: 'box-shadow-medium',
1332
+ },
1333
+ {
1334
+ value: 'var(--color-shadow-large)',
1335
+ utilityClass: 'box-shadow-large',
1336
+ },
1337
+ {
1338
+ value: 'var(--color-shadow-extra-large)',
1339
+ utilityClass: 'box-shadow-extra-large',
1340
+ },
1341
+ ],
1342
+ border: [
1343
+ {
1344
+ value: '$border',
1345
+ utilityClass: 'border',
1346
+ },
1347
+ {
1348
+ value: '0',
1349
+ utilityClass: 'border-0',
1350
+ },
1351
+ ],
1352
+ 'border-top': [
1353
+ {
1354
+ value: '$border',
1355
+ utilityClass: 'border-top',
1356
+ },
1357
+ {
1358
+ value: '0',
1359
+ utilityClass: 'border-top-0',
1360
+ },
1361
+ ],
1362
+ 'border-right': [
1363
+ {
1364
+ value: '$border',
1365
+ utilityClass: 'border-right',
1366
+ },
1367
+ {
1368
+ value: '0',
1369
+ utilityClass: 'border-right-0',
1370
+ },
1371
+ ],
1372
+ 'border-bottom': [
1373
+ {
1374
+ value: '$border',
1375
+ utilityClass: 'border-bottom',
1376
+ },
1377
+ {
1378
+ value: '0',
1379
+ utilityClass: 'border-bottom-0',
1380
+ },
1381
+ ],
1382
+ 'border-left': [
1383
+ {
1384
+ value: '$border',
1385
+ utilityClass: 'border-left',
1386
+ },
1387
+ {
1388
+ value: '0',
1389
+ utilityClass: 'border-left-0',
1390
+ },
1391
+ ],
1392
+ };
1393
+
1394
+ const ruleName$1 = 'primer/utilities';
1395
+
1396
+ const messages$1 = stylelint.utils.ruleMessages(ruleName$1, {
1397
+ rejected: (selector, utilityClass) => {
1398
+ return `Consider using the Primer utility '.${utilityClass}' instead of the selector '${selector}' in your html. https://primer.style/css/utilities`
1399
+ },
1400
+ });
1401
+
1402
+ // eslint-disable-next-line no-unused-vars
1403
+ var utilities = stylelint.createPlugin(ruleName$1, (enabled, options = {}, context) => {
1404
+ if (!enabled) {
1405
+ return noop$1
1406
+ }
1407
+
1408
+ const utilityReplacement = (declaration, value) => {
1409
+ const declarationUtilities = utilities$1[declaration];
1410
+ if (declarationUtilities) {
1411
+ return declarationUtilities.find(utility => {
1412
+ return utility.value === value
1413
+ })
1414
+ }
1415
+ };
1416
+
1417
+ const lintResult = (root, result) => {
1418
+ root.walkRules(rule => {
1419
+ if (!/^\.[\w\-_]+$/.exec(rule.selector)) {
1420
+ return
1421
+ }
1422
+ const decls = rule.nodes.filter(decl => decl.type === 'decl');
1423
+
1424
+ if (decls.length === 1) {
1425
+ const replacement = utilityReplacement(decls[0].prop, decls[0].value);
1426
+ if (replacement) {
1427
+ stylelint.utils.report({
1428
+ index: rule.sourceIndex,
1429
+ message: messages$1.rejected(rule.selector, replacement.utilityClass),
1430
+ node: rule,
1431
+ result,
1432
+ ruleName: ruleName$1,
1433
+ });
1434
+ }
1435
+ }
1436
+ });
1437
+ };
1438
+
1439
+ return lintResult
1440
+ });
1441
+
1442
+ function noop$1() {}
1443
+
1444
+ const ruleName = 'primer/no-display-colors';
1445
+ const messages = stylelint.utils.ruleMessages(ruleName, {
1446
+ rejected: varName => `${varName} is in alpha and should be used with caution with approval from the Primer team`,
1447
+ });
1448
+
1449
+ // Match CSS variable references (e.g var(--display-blue-fgColor))
1450
+ // eslint-disable-next-line no-useless-escape
1451
+ const variableReferenceRegex = /var\(([^\),]+)(,.*)?\)/g;
1452
+
1453
+ var noDisplayColors = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
1454
+ if (!enabled) {
1455
+ return noop
1456
+ }
1457
+
1458
+ const {verbose = false} = options;
1459
+ // eslint-disable-next-line no-console
1460
+ const log = verbose ? (...args) => console.warn(...args) : noop;
1461
+
1462
+ // Keep track of declarations we've already seen
1463
+ const seen = new WeakMap();
1464
+
1465
+ return (root, result) => {
1466
+ root.walkRules(rule => {
1467
+ rule.walkDecls(decl => {
1468
+ if (seen.has(decl)) {
1469
+ return
1470
+ } else {
1471
+ seen.set(decl, true);
1472
+ }
1473
+
1474
+ for (const [, variableName] of matchAll(decl.value, variableReferenceRegex)) {
1475
+ log(`Found variable reference ${variableName}`);
1476
+ if (variableName.match(/^--display-.*/)) {
1477
+ stylelint.utils.report({
1478
+ message: messages.rejected(variableName),
1479
+ node: decl,
1480
+ result,
1481
+ ruleName,
1482
+ });
1483
+ }
1484
+ }
1485
+ });
1486
+ });
1487
+ }
1488
+ });
1489
+
1490
+ function noop() {}
1491
+
1492
+ const require = createRequire(import.meta.url);
1493
+
1494
+ /** @type {import('stylelint').Config} */
1495
+ var index = {
1496
+ extends: ['stylelint-config-standard'],
1497
+ ignoreFiles: ['**/*.js', '**/*.cjs', '**/*.ts', '**/*.mjs'],
1498
+ reportNeedlessDisables: true,
1499
+ plugins: [
1500
+ 'stylelint-value-no-unknown-custom-properties',
1501
+ 'stylelint-no-unsupported-browser-features',
1502
+ 'stylelint-order',
1503
+ borders,
1504
+ boxShadow,
1505
+ colors,
1506
+ responsiveWidths,
1507
+ spacing,
1508
+ typography,
1509
+ utilities,
1510
+ noDisplayColors,
1511
+ ],
1512
+ rules: {
1513
+ 'alpha-value-notation': 'number',
1514
+ 'at-rule-disallowed-list': ['extend'],
1515
+ 'at-rule-no-unknown': null,
1516
+ 'block-no-empty': true,
1517
+ 'color-function-notation': null,
1518
+ 'color-named': 'never',
1519
+ 'color-no-invalid-hex': true,
1520
+ 'comment-no-empty': null,
1521
+ 'csstools/value-no-unknown-custom-properties': [
1522
+ true,
1523
+ {
1524
+ severity: 'warning',
1525
+ importFrom: [
1526
+ '@primer/primitives/dist/css/functional/size/size-coarse.css',
1527
+ '@primer/primitives/dist/css/functional/size/border.css',
1528
+ '@primer/primitives/dist/css/functional/size/size.css',
1529
+ '@primer/primitives/dist/css/functional/size/size-fine.css',
1530
+ '@primer/primitives/dist/css/functional/size/breakpoints.css',
1531
+ '@primer/primitives/dist/css/functional/size/viewport.css',
1532
+ '@primer/primitives/dist/css/functional/motion/motion.css',
1533
+ '@primer/primitives/dist/css/functional/themes/light.css',
1534
+ '@primer/primitives/dist/css/functional/typography/typography.css',
1535
+ '@primer/primitives/dist/css/base/size/size.css',
1536
+ '@primer/primitives/dist/css/base/typography/typography.css',
1537
+ ].map(path => require.resolve(path)),
1538
+ },
1539
+ ],
1540
+ 'custom-property-pattern': null,
1541
+ 'declaration-block-no-duplicate-properties': [true, {ignore: ['consecutive-duplicates']}],
1542
+ 'declaration-block-no-redundant-longhand-properties': null,
1543
+ 'declaration-block-no-shorthand-property-overrides': true,
1544
+ 'declaration-property-value-disallowed-list': {
1545
+ '/^transition/': ['/all/'],
1546
+ '/^background/': ['http:', 'https:'],
1547
+ '/^border/': ['none'],
1548
+ '/.+/': ['initial'],
1549
+ },
1550
+ 'function-calc-no-unspaced-operator': true,
1551
+ 'function-linear-gradient-no-nonstandard-direction': true,
1552
+ 'function-no-unknown': null,
1553
+ 'keyframes-name-pattern': null,
1554
+ 'max-nesting-depth': 3,
1555
+ 'media-feature-name-no-unknown': null,
1556
+ 'media-feature-name-no-vendor-prefix': null,
1557
+ 'no-descending-specificity': null,
1558
+ 'no-duplicate-selectors': true,
1559
+ 'no-invalid-position-at-import-rule': [true, {ignoreAtRules: ['use']}],
1560
+ 'number-max-precision': null,
1561
+ 'order/properties-order': propertyOrder,
1562
+ 'plugin/no-unsupported-browser-features': [
1563
+ true,
1564
+ {
1565
+ severity: 'warning',
1566
+ ignore: ['css-nesting'],
1567
+ ignorePartialSupport: true,
1568
+ browsers,
1569
+ },
1570
+ ],
1571
+ 'primer/borders': true,
1572
+ 'primer/box-shadow': true,
1573
+ 'primer/colors': true,
1574
+ 'primer/responsive-widths': true,
1575
+ 'primer/spacing': true,
1576
+ 'primer/typography': true,
1577
+ 'primer/utilities': null,
1578
+ 'primer/no-display-colors': true,
1579
+ 'property-no-unknown': [
1580
+ true,
1581
+ {
1582
+ ignoreProperties: ['@container', 'container-type'],
1583
+ },
1584
+ ],
1585
+ 'selector-class-pattern': null,
1586
+ 'selector-max-compound-selectors': 3,
1587
+ 'selector-max-id': 0,
1588
+ 'selector-max-specificity': '0,4,0',
1589
+ 'selector-max-type': 0,
1590
+ 'selector-no-qualifying-type': true,
1591
+ 'selector-pseudo-element-no-unknown': true,
1592
+ 'string-no-newline': true,
1593
+ 'unit-no-unknown': true,
1594
+ 'value-keyword-case': null,
1595
+ 'selector-not-notation': null,
1596
+ 'import-notation': ['string'],
1597
+ 'annotation-no-unknown': null,
1598
+ 'keyframe-selector-notation': ['percentage-unless-within-keyword-only-block'],
1599
+ 'media-query-no-invalid': null,
1600
+ 'media-feature-range-notation': ['prefix'],
1601
+ },
1602
+ overrides: [
1603
+ {
1604
+ files: ['**/*.scss'],
1605
+ customSyntax: 'postcss-scss',
1606
+ plugins: ['stylelint-scss'],
1607
+ rules: {
1608
+ 'scss/at-extend-no-missing-placeholder': true,
1609
+ 'scss/at-rule-no-unknown': true,
1610
+ 'scss/declaration-nested-properties-no-divided-groups': true,
1611
+ 'scss/dollar-variable-no-missing-interpolation': true,
1612
+ 'scss/function-quote-no-quoted-strings-inside': true,
1613
+ 'scss/function-unquote-no-unquoted-strings-inside': true,
1614
+ 'scss/no-duplicate-mixins': true,
1615
+ 'scss/selector-no-redundant-nesting-selector': true,
1616
+ },
1617
+ },
1618
+ {
1619
+ files: ['**/*.tsx'],
1620
+ customSyntax: 'postcss-styled-syntax',
1621
+ rules: {
1622
+ 'order/properties-order': null,
1623
+ 'rule-empty-line-before': null,
1624
+ 'declaration-empty-line-before': null,
1625
+ 'comment-empty-line-before': null,
1626
+ 'length-zero-no-unit': null,
1627
+ 'selector-max-type': null,
1628
+ 'primer/spacing': null,
1629
+ 'primer/colors': null,
1630
+ 'primer/borders': null,
1631
+ 'primer/typography': null,
1632
+ 'primer/box-shadow': null,
1633
+ 'primer/utilities': null,
1634
+ },
1635
+ },
1636
+ {
1637
+ files: ['**/*.pcss'],
1638
+ rules: {
1639
+ 'media-feature-range-notation': null,
1640
+ 'import-notation': null,
1641
+ 'custom-property-pattern': null,
1642
+ 'selector-class-pattern': null,
1643
+ 'keyframes-name-pattern': null,
1644
+ 'no-descending-specificity': null,
1645
+ 'declaration-block-no-redundant-longhand-properties': null,
1646
+ 'color-function-notation': 'legacy',
1647
+ 'selector-nested-pattern': '^&\\s?\\W',
1648
+ 'at-rule-no-unknown': [
1649
+ true,
1650
+ {
1651
+ ignoreAtRules: ['mixin', 'define-mixin'],
1652
+ },
1653
+ ],
1654
+ },
1655
+ },
1656
+ {
1657
+ files: ['**/*.module.css'],
1658
+ rules: {
1659
+ // Don't support nesting until it's more broadly shipped
1660
+ 'max-nesting-depth': [0],
1661
+ 'property-no-unknown': [
1662
+ true,
1663
+ {
1664
+ ignoreProperties: ['composes', 'compose-with'],
1665
+ ignoreSelectors: [':export', /^:import/],
1666
+ },
1667
+ ],
1668
+ 'selector-pseudo-class-no-unknown': [
1669
+ true,
1670
+ {ignorePseudoClasses: ['export', 'import', 'global', 'local', 'external']},
1671
+ ],
1672
+ 'selector-type-no-unknown': [
1673
+ true,
1674
+ {
1675
+ ignoreTypes: ['from'],
1676
+ },
1677
+ ],
1678
+ 'function-no-unknown': [
1679
+ true,
1680
+ {
1681
+ ignoreFunctions: ['global'],
1682
+ },
1683
+ ],
1684
+ // temporarily disabiling Primer plugins while we work on upgrades https://github.com/github/primer/issues/3165
1685
+ 'primer/spacing': null,
1686
+ 'primer/borders': null,
1687
+ 'primer/typography': null,
1688
+ 'primer/box-shadow': null,
1689
+ 'primer/utilities': null,
1690
+ },
1691
+ },
1692
+ ],
1693
+ };
1694
+
1695
+ export { index as default };