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