@primer/stylelint-config 13.0.0-rc.51f6efe → 13.0.0-rc.54c7a2f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import browsers from '@github/browserslist-config';
2
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
3
  import declarationValueIndex from 'stylelint/lib/utils/declarationValueIndex.cjs';
4
+ import valueParser from 'postcss-value-parser';
8
5
  import { createRequire } from 'node:module';
6
+ import anymatch from 'anymatch';
7
+ import TapMap from 'tap-map';
8
+ import variables$1 from '@primer/css/dist/variables.json' assert { type: 'json' };
9
9
  import matchAll from 'string.prototype.matchall';
10
10
 
11
11
  var propertyOrder = [
@@ -181,6 +181,243 @@ var propertyOrder = [
181
181
  'animation-direction',
182
182
  ];
183
183
 
184
+ const require$1 = createRequire(import.meta.url);
185
+
186
+ function primitivesVariables(type) {
187
+ const variables = [];
188
+
189
+ const files = [];
190
+ switch (type) {
191
+ case 'spacing':
192
+ files.push('base/size/size.json');
193
+ break
194
+ case 'border':
195
+ files.push('functional/size/border.json');
196
+ break
197
+ }
198
+
199
+ for (const file of files) {
200
+ // eslint-disable-next-line import/no-dynamic-require
201
+ const data = require$1(`@primer/primitives/dist/styleLint/${file}`);
202
+
203
+ for (const key of Object.keys(data)) {
204
+ const size = data[key];
205
+ const values = typeof size['value'] === 'string' ? [size['value']] : size['value'];
206
+
207
+ variables.push({
208
+ name: `--${size['name']}`,
209
+ values,
210
+ });
211
+ }
212
+ }
213
+
214
+ return variables
215
+ }
216
+
217
+ function walkGroups$1(root, validate) {
218
+ for (const node of root.nodes) {
219
+ if (node.type === 'function') {
220
+ walkGroups$1(node, validate);
221
+ } else {
222
+ validate(node);
223
+ }
224
+ }
225
+ return root
226
+ }
227
+
228
+ const {
229
+ createPlugin: createPlugin$1,
230
+ utils: {report: report$1, ruleMessages: ruleMessages$1, validateOptions: validateOptions$1},
231
+ } = stylelint;
232
+
233
+ const ruleName$3 = 'primer/borders';
234
+ const messages$3 = ruleMessages$1(ruleName$3, {
235
+ rejected: (value, replacement, propName) => {
236
+ if (propName && propName.includes('radius') && value.includes('borderWidth')) {
237
+ return `Border radius variables can not be used for border widths`
238
+ }
239
+
240
+ if ((propName && propName.includes('width')) || (borderShorthand(propName) && value.includes('borderRadius'))) {
241
+ return `Border width variables can not be used for border radii`
242
+ }
243
+
244
+ if (!replacement) {
245
+ return `Please use a Primer border variable instead of '${value}'. Consult the primer docs for a suitable replacement. https://primer.style/foundations/primitives/size#border`
246
+ }
247
+
248
+ return `Please replace '${value}' with a Primer border variable '${replacement['name']}'. https://primer.style/foundations/primitives/size#border`
249
+ },
250
+ });
251
+
252
+ const variables = primitivesVariables('border');
253
+ const sizes$1 = [];
254
+ const radii = [];
255
+
256
+ // Props that we want to check
257
+ const propList$1 = ['border', 'border-width', 'border-radius'];
258
+ // Values that we want to ignore
259
+ const valueList$1 = ['${'];
260
+
261
+ const borderShorthand = prop =>
262
+ /^border(-(top|right|bottom|left|block-start|block-end|inline-start|inline-end))?$/.test(prop);
263
+
264
+ for (const variable of variables) {
265
+ const name = variable['name'];
266
+
267
+ if (name.includes('borderWidth')) {
268
+ const value = variable['values']
269
+ .pop()
270
+ .replace(/max|\(|\)/g, '')
271
+ .split(',')[0];
272
+ sizes$1.push({
273
+ name,
274
+ values: [value],
275
+ });
276
+ }
277
+
278
+ if (name.includes('borderRadius')) {
279
+ radii.push(variable);
280
+ }
281
+ }
282
+
283
+ /** @type {import('stylelint').Rule} */
284
+ const ruleFunction$1 = (primary, secondaryOptions, context) => {
285
+ return (root, result) => {
286
+ const validOptions = validateOptions$1(result, ruleName$3, {
287
+ actual: primary,
288
+ possible: [true],
289
+ });
290
+
291
+ if (!validOptions) return
292
+
293
+ root.walkDecls(declNode => {
294
+ const {prop, value} = declNode;
295
+
296
+ if (!propList$1.some(borderProp => prop.startsWith(borderProp))) return
297
+ if (/^border(-(top|right|bottom|left|block-start|block-end|inline-start|inline-end))?-color$/.test(prop)) return
298
+ if (valueList$1.some(valueToIgnore => value.includes(valueToIgnore))) return
299
+
300
+ const problems = [];
301
+
302
+ const parsedValue = walkGroups$1(valueParser(value), node => {
303
+ const checkForVariable = (vars, nodeValue) =>
304
+ vars.some(variable =>
305
+ new RegExp(`${variable['name'].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(nodeValue),
306
+ );
307
+
308
+ // Only check word types. https://github.com/TrySound/postcss-value-parser#word
309
+ if (node.type !== 'word') {
310
+ return
311
+ }
312
+
313
+ // Exact values to ignore.
314
+ if (
315
+ [
316
+ '*',
317
+ '+',
318
+ '-',
319
+ '/',
320
+ '0',
321
+ 'none',
322
+ 'inherit',
323
+ 'initial',
324
+ 'revert',
325
+ 'revert-layer',
326
+ 'unset',
327
+ 'solid',
328
+ 'dashed',
329
+ 'dotted',
330
+ 'transparent',
331
+ ].includes(node.value)
332
+ ) {
333
+ return
334
+ }
335
+
336
+ const valueUnit = valueParser.unit(node.value);
337
+
338
+ if (valueUnit && (valueUnit.unit === '' || !/^-?[0-9.]+$/.test(valueUnit.number))) {
339
+ return
340
+ }
341
+
342
+ // Skip if the value unit isn't a supported unit.
343
+ if (valueUnit && !['px', 'rem', 'em'].includes(valueUnit.unit)) {
344
+ return
345
+ }
346
+
347
+ // if we're looking at the border property that sets color in shorthand, don't bother checking the color
348
+ if (
349
+ // using border shorthand
350
+ borderShorthand(prop) &&
351
+ // includes a color as a third space-separated value
352
+ value.split(' ').length > 2 &&
353
+ // the color in the third space-separated value includes `node.value`
354
+ value
355
+ .split(' ')
356
+ .slice(2)
357
+ .some(color => color.includes(node.value))
358
+ ) {
359
+ return
360
+ }
361
+
362
+ // If the variable is found in the value, skip it.
363
+ if (prop.includes('width') || borderShorthand(prop)) {
364
+ if (checkForVariable(sizes$1, node.value)) {
365
+ return
366
+ }
367
+ }
368
+
369
+ if (prop.includes('radius')) {
370
+ if (checkForVariable(radii, node.value)) {
371
+ return
372
+ }
373
+ }
374
+
375
+ const replacement = (prop.includes('radius') ? radii : sizes$1).find(variable =>
376
+ variable.values.includes(node.value.replace('-', '')),
377
+ );
378
+ const fixable = replacement && valueUnit && !valueUnit.number.includes('-');
379
+
380
+ if (fixable && context.fix) {
381
+ node.value = node.value.replace(node.value, `var(${replacement['name']})`);
382
+ } else {
383
+ problems.push({
384
+ index: declarationValueIndex(declNode) + node.sourceIndex,
385
+ endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
386
+ message: messages$3.rejected(node.value, replacement, prop),
387
+ });
388
+ }
389
+
390
+ return
391
+ });
392
+
393
+ if (context.fix) {
394
+ declNode.value = parsedValue.toString();
395
+ }
396
+
397
+ if (problems.length) {
398
+ for (const err of problems) {
399
+ report$1({
400
+ index: err.index,
401
+ endIndex: err.endIndex,
402
+ message: err.message,
403
+ node: declNode,
404
+ result,
405
+ ruleName: ruleName$3,
406
+ });
407
+ }
408
+ }
409
+ });
410
+ }
411
+ };
412
+
413
+ ruleFunction$1.ruleName = ruleName$3;
414
+ ruleFunction$1.messages = messages$3;
415
+ ruleFunction$1.meta = {
416
+ fixable: true,
417
+ };
418
+
419
+ var borders = createPlugin$1(ruleName$3, ruleFunction$1);
420
+
184
421
  const SKIP_VALUE_NODE_TYPES = new Set(['space', 'div']);
185
422
  const SKIP_AT_RULE_NAMES = new Set(['each', 'for', 'function', 'mixin']);
186
423
 
@@ -419,24 +656,24 @@ function closest(node, test) {
419
656
  function createVariableRule(ruleName, rules, url) {
420
657
  const plugin = stylelint.createPlugin(ruleName, (enabled, options = {}, context) => {
421
658
  if (enabled === false) {
422
- return noop$3
659
+ return noop$2
423
660
  }
424
661
 
425
662
  let actualRules = rules;
426
663
  let overrides = options.rules;
427
664
  if (typeof rules === 'function') {
428
- actualRules = rules({variables, options, ruleName});
665
+ actualRules = rules({variables: variables$1, options, ruleName});
429
666
  } else {
430
667
  actualRules = Object.assign({}, rules);
431
668
  }
432
669
  if (typeof overrides === 'function') {
433
670
  delete options.rules;
434
- overrides = overrides({rules: actualRules, options, ruleName, variables});
671
+ overrides = overrides({rules: actualRules, options, ruleName, variables: variables$1});
435
672
  }
436
673
  if (overrides) {
437
674
  Object.assign(actualRules, overrides);
438
675
  }
439
- const validate = declarationValidator(actualRules, {variables});
676
+ const validate = declarationValidator(actualRules, {variables: variables$1});
440
677
 
441
678
  // The stylelint docs suggest respecting a "disableFix" rule option that
442
679
  // overrides the "global" context.fix (--fix) linting option.
@@ -496,70 +733,7 @@ function createVariableRule(ruleName, rules, url) {
496
733
  return plugin
497
734
  }
498
735
 
499
- function noop$3() {}
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
- );
736
+ function noop$2() {}
563
737
 
564
738
  var boxShadow = createVariableRule(
565
739
  'primer/box-shadow',
@@ -624,9 +798,9 @@ var colors = createVariableRule(
624
798
  'https://primer.style/primitives/colors',
625
799
  );
626
800
 
627
- const ruleName$3 = 'primer/responsive-widths';
801
+ const ruleName$2 = 'primer/responsive-widths';
628
802
 
629
- const messages$3 = stylelint.utils.ruleMessages(ruleName$3, {
803
+ const messages$2 = stylelint.utils.ruleMessages(ruleName$2, {
630
804
  rejected: value => {
631
805
  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
806
  },
@@ -634,10 +808,10 @@ const messages$3 = stylelint.utils.ruleMessages(ruleName$3, {
634
808
 
635
809
  // 320px is the smallest viewport size that we support
636
810
 
637
- const walkGroups$1 = (root, validate) => {
811
+ const walkGroups = (root, validate) => {
638
812
  for (const node of root.nodes) {
639
813
  if (node.type === 'function') {
640
- walkGroups$1(node, validate);
814
+ walkGroups(node, validate);
641
815
  } else {
642
816
  validate(node);
643
817
  }
@@ -646,9 +820,9 @@ const walkGroups$1 = (root, validate) => {
646
820
  };
647
821
 
648
822
  // eslint-disable-next-line no-unused-vars
649
- var responsiveWidths = stylelint.createPlugin(ruleName$3, (enabled, options = {}, context) => {
823
+ var responsiveWidths = stylelint.createPlugin(ruleName$2, (enabled, options = {}, context) => {
650
824
  if (!enabled) {
651
- return noop$2
825
+ return noop$1
652
826
  }
653
827
 
654
828
  const lintResult = (root, result) => {
@@ -659,12 +833,12 @@ var responsiveWidths = stylelint.createPlugin(ruleName$3, (enabled, options = {}
659
833
  }
660
834
 
661
835
  if (decl.type !== 'decl' || !decl.prop.match(/^(min-width|width)/)) {
662
- return noop$2
836
+ return noop$1
663
837
  }
664
838
 
665
839
  const problems = [];
666
840
 
667
- walkGroups$1(valueParser(decl.value), node => {
841
+ walkGroups(valueParser(decl.value), node => {
668
842
  // Only check word types. https://github.com/TrySound/postcss-value-parser#word
669
843
  if (node.type !== 'word') {
670
844
  return
@@ -682,7 +856,7 @@ var responsiveWidths = stylelint.createPlugin(ruleName$3, (enabled, options = {}
682
856
  if (parseInt(valueUnit.number) > 320) {
683
857
  problems.push({
684
858
  index: declarationValueIndex(decl) + node.sourceIndex,
685
- message: messages$3.rejected(node.value),
859
+ message: messages$2.rejected(node.value),
686
860
  });
687
861
  }
688
862
  break
@@ -690,7 +864,7 @@ var responsiveWidths = stylelint.createPlugin(ruleName$3, (enabled, options = {}
690
864
  if (parseInt(valueUnit.number) > 100) {
691
865
  problems.push({
692
866
  index: declarationValueIndex(decl) + node.sourceIndex,
693
- message: messages$3.rejected(node.value),
867
+ message: messages$2.rejected(node.value),
694
868
  });
695
869
  }
696
870
  break
@@ -704,7 +878,7 @@ var responsiveWidths = stylelint.createPlugin(ruleName$3, (enabled, options = {}
704
878
  message: err.message,
705
879
  node: decl,
706
880
  result,
707
- ruleName: ruleName$3,
881
+ ruleName: ruleName$2,
708
882
  });
709
883
  }
710
884
  }
@@ -714,58 +888,15 @@ var responsiveWidths = stylelint.createPlugin(ruleName$3, (enabled, options = {}
714
888
  return lintResult
715
889
  });
716
890
 
717
- function noop$2() {}
718
-
719
- const require$1 = createRequire(import.meta.url);
720
-
721
- async function primitivesVariables(type) {
722
- const variables = [];
723
-
724
- const files = [];
725
- switch (type) {
726
- case 'size':
727
- files.push('base/size/size.json');
728
- break
729
- }
730
-
731
- for (const file of files) {
732
- // eslint-disable-next-line import/no-dynamic-require
733
- const data = require$1(`@primer/primitives/dist/styleLint/${file}`);
734
-
735
- for (const key of Object.keys(data)) {
736
- const size = data[key];
737
- const values = size['value'];
738
- values.push(`${parseInt(size['original']['value']) + 1}px`);
739
- values.push(`${parseInt(size['original']['value']) - 1}px`);
740
-
741
- variables.push({
742
- name: `--${size['name']}`,
743
- values,
744
- });
745
- }
746
- }
747
-
748
- return variables
749
- }
891
+ function noop$1() {}
750
892
 
751
893
  const {
752
894
  createPlugin,
753
895
  utils: {report, ruleMessages, validateOptions},
754
896
  } = stylelint;
755
897
 
756
- const walkGroups = (root, validate) => {
757
- for (const node of root.nodes) {
758
- if (node.type === 'function') {
759
- walkGroups(node, validate);
760
- } else {
761
- validate(node);
762
- }
763
- }
764
- return root
765
- };
766
-
767
- const ruleName$2 = 'primer/spacing';
768
- const messages$2 = ruleMessages(ruleName$2, {
898
+ const ruleName$1 = 'primer/spacing';
899
+ const messages$1 = ruleMessages(ruleName$1, {
769
900
  rejected: (value, replacement) => {
770
901
  if (!replacement) {
771
902
  return `Please use a primer size variable instead of '${value}'. Consult the primer docs for a suitable replacement. https://primer.style/foundations/primitives/size`
@@ -775,21 +906,27 @@ const messages$2 = ruleMessages(ruleName$2, {
775
906
  },
776
907
  });
777
908
 
778
- const meta = {
779
- fixable: true,
780
- };
909
+ // Props that we want to check
910
+ const propList = ['padding', 'margin', 'top', 'right', 'bottom', 'left'];
911
+ // Values that we want to ignore
912
+ const valueList = ['${'];
781
913
 
782
- /** @type {import('stylelint').Rule} */
783
- const ruleFunction = (primary, secondaryOptions, context) => {
784
- return async (root, result) => {
785
- // Props that we want to check
786
- const propList = ['padding', 'margin', 'top', 'right', 'bottom', 'left'];
787
- // Values that we want to ignore
788
- const valueList = ['${'];
914
+ const sizes = primitivesVariables('spacing');
789
915
 
790
- const sizes = await primitivesVariables('size');
916
+ // Add +-1px to each value
917
+ for (const size of sizes) {
918
+ const values = size['values'];
919
+ const px = parseInt(values.find(value => value.includes('px')));
920
+ if (![2, 6].includes(px)) {
921
+ values.push(`${px + 1}px`);
922
+ values.push(`${px - 1}px`);
923
+ }
924
+ }
791
925
 
792
- const validOptions = validateOptions(result, ruleName$2, {
926
+ /** @type {import('stylelint').Rule} */
927
+ const ruleFunction = (primary, secondaryOptions, context) => {
928
+ return (root, result) => {
929
+ const validOptions = validateOptions(result, ruleName$1, {
793
930
  actual: primary,
794
931
  possible: [true],
795
932
  });
@@ -804,7 +941,7 @@ const ruleFunction = (primary, secondaryOptions, context) => {
804
941
 
805
942
  const problems = [];
806
943
 
807
- const parsedValue = walkGroups(valueParser(value), node => {
944
+ const parsedValue = walkGroups$1(valueParser(value), node => {
808
945
  // Only check word types. https://github.com/TrySound/postcss-value-parser#word
809
946
  if (node.type !== 'word') {
810
947
  return
@@ -844,7 +981,7 @@ const ruleFunction = (primary, secondaryOptions, context) => {
844
981
  problems.push({
845
982
  index: declarationValueIndex(declNode) + node.sourceIndex,
846
983
  endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
847
- message: messages$2.rejected(node.value, replacement),
984
+ message: messages$1.rejected(node.value, replacement),
848
985
  });
849
986
  }
850
987
 
@@ -863,7 +1000,7 @@ const ruleFunction = (primary, secondaryOptions, context) => {
863
1000
  message: err.message,
864
1001
  node: declNode,
865
1002
  result,
866
- ruleName: ruleName$2,
1003
+ ruleName: ruleName$1,
867
1004
  });
868
1005
  }
869
1006
  }
@@ -871,11 +1008,13 @@ const ruleFunction = (primary, secondaryOptions, context) => {
871
1008
  }
872
1009
  };
873
1010
 
874
- ruleFunction.ruleName = ruleName$2;
875
- ruleFunction.messages = messages$2;
876
- ruleFunction.meta = meta;
1011
+ ruleFunction.ruleName = ruleName$1;
1012
+ ruleFunction.messages = messages$1;
1013
+ ruleFunction.meta = {
1014
+ fixable: true,
1015
+ };
877
1016
 
878
- var spacing = createPlugin(ruleName$2, ruleFunction);
1017
+ var spacing = createPlugin(ruleName$1, ruleFunction);
879
1018
 
880
1019
  var typography = createVariableRule(
881
1020
  'primer/typography',
@@ -900,583 +1039,6 @@ var typography = createVariableRule(
900
1039
  'https://primer.style/css/utilities/typography',
901
1040
  );
902
1041
 
903
- // Meant as temp until we can move to primitives or css
904
- const colorTypes = ['accent', 'success', 'attention', 'severe', 'danger', 'open', 'closed', 'done', 'sponsors'];
905
-
906
- var utilities$1 = {
907
- color: [
908
- {
909
- value: 'var(--color-fg-default)',
910
- utilityClass: 'color-fg-default',
911
- },
912
- {
913
- value: 'var(--color-fg-muted)',
914
- utilityClass: 'color-fg-muted',
915
- },
916
- {
917
- value: 'var(--color-fg-subtle)',
918
- utilityClass: 'color-fg-subtle',
919
- },
920
- ].concat(
921
- colorTypes.map(type => {
922
- return {
923
- value: `var(--color-${type}-fg)`,
924
- utilityClass: `color-fg-${type}`,
925
- }
926
- }),
927
- ),
928
- 'background-color': [
929
- {
930
- value: 'var(--color-canvas-default)',
931
- utilityClass: 'color-bg-default',
932
- },
933
- {
934
- value: 'var(--color-canvas-overlay)',
935
- utilityClass: 'color-bg-overlay',
936
- },
937
- {
938
- value: 'var(--color-canvas-inset)',
939
- utilityClass: 'color-bg-inset',
940
- },
941
- {
942
- value: 'var(--color-canvas-subtle)',
943
- utilityClass: 'color-bg-subtle',
944
- },
945
- {
946
- value: 'transparent',
947
- utilityClass: 'color-bg-transparent',
948
- },
949
- ]
950
- .concat(
951
- colorTypes.map(type => {
952
- return {
953
- value: `var(--color-${type}-subtle)`,
954
- utilityClass: `color-bg-${type}`,
955
- }
956
- }),
957
- )
958
- .concat(
959
- colorTypes.map(type => {
960
- return {
961
- value: `var(--color-${type}-emphasis)`,
962
- utilityClass: `color-bg-${type}-emphasis`,
963
- }
964
- }),
965
- ),
966
- 'border-color': [
967
- {
968
- value: 'var(--color-border-default',
969
- utilityClass: 'color-border-default',
970
- },
971
- {
972
- value: 'var(--color-border-muted',
973
- utilityClass: 'color-border-muted',
974
- },
975
- {
976
- value: 'var(--color-border-subtle',
977
- utilityClass: 'color-border-subtle',
978
- },
979
- ]
980
- .concat(
981
- colorTypes.map(type => {
982
- return {
983
- value: `var(--color-${type}-muted)`,
984
- utilityClass: `color-border-${type}`,
985
- }
986
- }),
987
- )
988
- .concat(
989
- colorTypes.map(type => {
990
- return {
991
- value: `var(--color-${type}-emphasis)`,
992
- utilityClass: `color-border-${type}-emphasis`,
993
- }
994
- }),
995
- ),
996
- margin: Array.from(new Array(6)).map((_, i) => {
997
- return {
998
- value: `$spacer-${i + 1}`,
999
- utilityClass: `m-${i + 1}`,
1000
- }
1001
- }),
1002
- 'margin-top': Array.from(new Array(6)).map((_, i) => {
1003
- return {
1004
- value: `$spacer-${i + 1}`,
1005
- utilityClass: `mt-${i + 1}`,
1006
- }
1007
- }),
1008
- 'margin-right': Array.from(new Array(6)).map((_, i) => {
1009
- return {
1010
- value: `$spacer-${i + 1}`,
1011
- utilityClass: `mr-${i + 1}`,
1012
- }
1013
- }),
1014
- 'margin-bottom': Array.from(new Array(6)).map((_, i) => {
1015
- return {
1016
- value: `$spacer-${i + 1}`,
1017
- utilityClass: `mb-${i + 1}`,
1018
- }
1019
- }),
1020
- 'margin-left': Array.from(new Array(6)).map((_, i) => {
1021
- return {
1022
- value: `$spacer-${i + 1}`,
1023
- utilityClass: `ml-${i + 1}`,
1024
- }
1025
- }),
1026
- padding: Array.from(new Array(6)).map((_, i) => {
1027
- return {
1028
- value: `$spacer-${i + 1}`,
1029
- utilityClass: `p-${i + 1}`,
1030
- }
1031
- }),
1032
- 'padding-top': Array.from(new Array(6)).map((_, i) => {
1033
- return {
1034
- value: `$spacer-${i + 1}`,
1035
- utilityClass: `pt-${i + 1}`,
1036
- }
1037
- }),
1038
- 'padding-right': Array.from(new Array(6)).map((_, i) => {
1039
- return {
1040
- value: `$spacer-${i + 1}`,
1041
- utilityClass: `pr-${i + 1}`,
1042
- }
1043
- }),
1044
- 'padding-bottom': Array.from(new Array(6)).map((_, i) => {
1045
- return {
1046
- value: `$spacer-${i + 1}`,
1047
- utilityClass: `pb-${i + 1}`,
1048
- }
1049
- }),
1050
- 'padding-left': Array.from(new Array(6)).map((_, i) => {
1051
- return {
1052
- value: `$spacer-${i + 1}`,
1053
- utilityClass: `pl-${i + 1}`,
1054
- }
1055
- }),
1056
- 'line-height': [
1057
- {
1058
- value: '$lh-condensed-ultra',
1059
- utilityClass: 'lh-condensed-ultra',
1060
- },
1061
- {
1062
- value: '$lh-condensed',
1063
- utilityClass: 'lh-condensed',
1064
- },
1065
- {
1066
- value: '$lh-default',
1067
- utilityClass: 'lh-default',
1068
- },
1069
- {
1070
- value: '0',
1071
- utilityClass: 'lh-0',
1072
- },
1073
- ],
1074
- 'text-align': [
1075
- {
1076
- value: 'left',
1077
- utilityClass: 'text-left',
1078
- },
1079
- {
1080
- value: 'right',
1081
- utilityClass: 'text-right',
1082
- },
1083
- {
1084
- value: 'center',
1085
- utilityClass: 'text-center',
1086
- },
1087
- ],
1088
- 'font-style': [
1089
- {
1090
- value: 'italic',
1091
- utilityClass: 'text-italic',
1092
- },
1093
- ],
1094
- 'text-transform': [
1095
- {
1096
- value: 'uppercase',
1097
- utilityClass: 'text-uppercase',
1098
- },
1099
- ],
1100
- 'text-decoration': [
1101
- {
1102
- value: 'underline',
1103
- utilityClass: 'text-underline',
1104
- },
1105
- {
1106
- value: 'none',
1107
- utilityClass: 'no-underline',
1108
- },
1109
- ],
1110
- 'white-space': [
1111
- {
1112
- value: 'nowrap',
1113
- utilityClass: 'no-wrap',
1114
- },
1115
- {
1116
- value: 'normal',
1117
- utilityClass: 'ws-normal',
1118
- },
1119
- ],
1120
- 'word-break': [
1121
- {
1122
- value: 'break-all',
1123
- utilityClass: 'wb-break-all',
1124
- },
1125
- ],
1126
- width: [
1127
- {
1128
- value: '100%',
1129
- utilityClass: 'width-full',
1130
- },
1131
- {
1132
- value: 'auto%',
1133
- utilityClass: 'width-auto',
1134
- },
1135
- ],
1136
- overflow: [
1137
- {
1138
- value: 'visible',
1139
- utilityClass: 'overflow-visible',
1140
- },
1141
- {
1142
- value: 'hidden',
1143
- utilityClass: 'overflow-hidden',
1144
- },
1145
- {
1146
- value: 'auto',
1147
- utilityClass: 'overflow-auto',
1148
- },
1149
- {
1150
- value: 'scroll',
1151
- utilityClass: 'overflow-scroll',
1152
- },
1153
- ],
1154
- 'overflow-x': [
1155
- {
1156
- value: 'visible',
1157
- utilityClass: 'overflow-x-visible',
1158
- },
1159
- {
1160
- value: 'hidden',
1161
- utilityClass: 'overflow-x-hidden',
1162
- },
1163
- {
1164
- value: 'auto',
1165
- utilityClass: 'overflow-x-auto',
1166
- },
1167
- {
1168
- value: 'scroll',
1169
- utilityClass: 'overflow-x-scroll',
1170
- },
1171
- ],
1172
- 'overflow-y': [
1173
- {
1174
- value: 'visible',
1175
- utilityClass: 'overflow-y-visible',
1176
- },
1177
- {
1178
- value: 'hidden',
1179
- utilityClass: 'overflow-y-hidden',
1180
- },
1181
- {
1182
- value: 'auto',
1183
- utilityClass: 'overflow-y-auto',
1184
- },
1185
- {
1186
- value: 'scroll',
1187
- utilityClass: 'overflow-y-scroll',
1188
- },
1189
- ],
1190
- height: [
1191
- {
1192
- value: '100%',
1193
- utilityClass: 'height-full',
1194
- },
1195
- ],
1196
- 'max-width': [
1197
- {
1198
- value: '100%',
1199
- utilityClass: 'width-fit',
1200
- },
1201
- ],
1202
- 'max-height': [
1203
- {
1204
- value: '100%',
1205
- utilityClass: 'height-fit',
1206
- },
1207
- ],
1208
- 'min-width': [
1209
- {
1210
- value: '0',
1211
- utilityClass: 'min-width-0',
1212
- },
1213
- ],
1214
- float: [
1215
- {
1216
- value: 'left',
1217
- utilityClass: 'float-left',
1218
- },
1219
- {
1220
- value: 'right',
1221
- utilityClass: 'float-right',
1222
- },
1223
- {
1224
- value: 'none',
1225
- utilityClass: 'float-none',
1226
- },
1227
- ],
1228
- 'list-style': [
1229
- {
1230
- value: 'none',
1231
- utilityClass: 'list-style-none',
1232
- },
1233
- ],
1234
- 'user-select': [
1235
- {
1236
- value: 'none',
1237
- utilityClass: 'user-select-none',
1238
- },
1239
- ],
1240
- visibility: [
1241
- {
1242
- value: 'hidden',
1243
- utilityClass: 'v-hidden',
1244
- },
1245
- {
1246
- value: 'visible',
1247
- utilityClass: 'v-visible',
1248
- },
1249
- ],
1250
- 'vertical-align': [
1251
- {
1252
- value: 'middle',
1253
- utilityClass: 'v-align-middle',
1254
- },
1255
- {
1256
- value: 'top',
1257
- utilityClass: 'v-align-top',
1258
- },
1259
- {
1260
- value: 'bottom',
1261
- utilityClass: 'v-align-bottom',
1262
- },
1263
- {
1264
- value: 'text-top',
1265
- utilityClass: 'v-align-text-top',
1266
- },
1267
- {
1268
- value: 'text-bottom',
1269
- utilityClass: 'v-align-text-bottom',
1270
- },
1271
- {
1272
- value: 'text-baseline',
1273
- utilityClass: 'v-align-baseline',
1274
- },
1275
- ],
1276
- 'font-weight': [
1277
- {
1278
- value: '$font-weight-normal',
1279
- utilityClass: 'text-normal',
1280
- },
1281
- {
1282
- value: '$font-weight-bold',
1283
- utilityClass: 'text-bold',
1284
- },
1285
- {
1286
- value: '$font-weight-semibold',
1287
- utilityClass: 'text-semibold',
1288
- },
1289
- {
1290
- value: '$font-weight-light',
1291
- utilityClass: 'text-light',
1292
- },
1293
- ],
1294
- top: [
1295
- {
1296
- value: '0',
1297
- utilityClass: 'top-0',
1298
- },
1299
- {
1300
- value: 'auto',
1301
- utilityClass: 'top-auto',
1302
- },
1303
- ],
1304
- right: [
1305
- {
1306
- value: '0',
1307
- utilityClass: 'right-0',
1308
- },
1309
- {
1310
- value: 'auto',
1311
- utilityClass: 'right-auto',
1312
- },
1313
- ],
1314
- bottom: [
1315
- {
1316
- value: '0',
1317
- utilityClass: 'bottom-0',
1318
- },
1319
- {
1320
- value: 'auto',
1321
- utilityClass: 'bottom-auto',
1322
- },
1323
- ],
1324
- left: [
1325
- {
1326
- value: '0',
1327
- utilityClass: 'left-0',
1328
- },
1329
- {
1330
- value: 'auto',
1331
- utilityClass: 'left-auto',
1332
- },
1333
- ],
1334
- position: [
1335
- {
1336
- value: 'static',
1337
- utilityClass: 'position-static',
1338
- },
1339
- {
1340
- value: 'relative',
1341
- utilityClass: 'position-relative',
1342
- },
1343
- {
1344
- value: 'absolute',
1345
- utilityClass: 'position-absolute',
1346
- },
1347
- {
1348
- value: 'fixed',
1349
- utilityClass: 'position-fixed',
1350
- },
1351
- {
1352
- value: 'sticky',
1353
- utilityClass: 'position-sticky',
1354
- },
1355
- ],
1356
- 'box-shadow': [
1357
- {
1358
- value: 'none',
1359
- utilityClass: 'box-shadow-none',
1360
- },
1361
- {
1362
- value: 'var(--color-shadow-small)',
1363
- utilityClass: 'box-shadow-small',
1364
- },
1365
- {
1366
- value: 'var(--color-shadow-medium)',
1367
- utilityClass: 'box-shadow-medium',
1368
- },
1369
- {
1370
- value: 'var(--color-shadow-large)',
1371
- utilityClass: 'box-shadow-large',
1372
- },
1373
- {
1374
- value: 'var(--color-shadow-extra-large)',
1375
- utilityClass: 'box-shadow-extra-large',
1376
- },
1377
- ],
1378
- border: [
1379
- {
1380
- value: '$border',
1381
- utilityClass: 'border',
1382
- },
1383
- {
1384
- value: '0',
1385
- utilityClass: 'border-0',
1386
- },
1387
- ],
1388
- 'border-top': [
1389
- {
1390
- value: '$border',
1391
- utilityClass: 'border-top',
1392
- },
1393
- {
1394
- value: '0',
1395
- utilityClass: 'border-top-0',
1396
- },
1397
- ],
1398
- 'border-right': [
1399
- {
1400
- value: '$border',
1401
- utilityClass: 'border-right',
1402
- },
1403
- {
1404
- value: '0',
1405
- utilityClass: 'border-right-0',
1406
- },
1407
- ],
1408
- 'border-bottom': [
1409
- {
1410
- value: '$border',
1411
- utilityClass: 'border-bottom',
1412
- },
1413
- {
1414
- value: '0',
1415
- utilityClass: 'border-bottom-0',
1416
- },
1417
- ],
1418
- 'border-left': [
1419
- {
1420
- value: '$border',
1421
- utilityClass: 'border-left',
1422
- },
1423
- {
1424
- value: '0',
1425
- utilityClass: 'border-left-0',
1426
- },
1427
- ],
1428
- };
1429
-
1430
- const ruleName$1 = 'primer/utilities';
1431
-
1432
- const messages$1 = stylelint.utils.ruleMessages(ruleName$1, {
1433
- rejected: (selector, utilityClass) => {
1434
- return `Consider using the Primer utility '.${utilityClass}' instead of the selector '${selector}' in your html. https://primer.style/css/utilities`
1435
- },
1436
- });
1437
-
1438
- // eslint-disable-next-line no-unused-vars
1439
- var utilities = stylelint.createPlugin(ruleName$1, (enabled, options = {}, context) => {
1440
- if (!enabled) {
1441
- return noop$1
1442
- }
1443
-
1444
- const utilityReplacement = (declaration, value) => {
1445
- const declarationUtilities = utilities$1[declaration];
1446
- if (declarationUtilities) {
1447
- return declarationUtilities.find(utility => {
1448
- return utility.value === value
1449
- })
1450
- }
1451
- };
1452
-
1453
- const lintResult = (root, result) => {
1454
- root.walkRules(rule => {
1455
- if (!/^\.[\w\-_]+$/.exec(rule.selector)) {
1456
- return
1457
- }
1458
- const decls = rule.nodes.filter(decl => decl.type === 'decl');
1459
-
1460
- if (decls.length === 1) {
1461
- const replacement = utilityReplacement(decls[0].prop, decls[0].value);
1462
- if (replacement) {
1463
- stylelint.utils.report({
1464
- index: rule.sourceIndex,
1465
- message: messages$1.rejected(rule.selector, replacement.utilityClass),
1466
- node: rule,
1467
- result,
1468
- ruleName: ruleName$1,
1469
- });
1470
- }
1471
- }
1472
- });
1473
- };
1474
-
1475
- return lintResult
1476
- });
1477
-
1478
- function noop$1() {}
1479
-
1480
1042
  const ruleName = 'primer/no-display-colors';
1481
1043
  const messages = stylelint.utils.ruleMessages(ruleName, {
1482
1044
  rejected: varName => `${varName} is in alpha and should be used with caution with approval from the Primer team`,
@@ -1542,7 +1104,6 @@ var index = {
1542
1104
  responsiveWidths,
1543
1105
  spacing,
1544
1106
  typography,
1545
- utilities,
1546
1107
  noDisplayColors,
1547
1108
  ],
1548
1109
  rules: {
@@ -1610,7 +1171,6 @@ var index = {
1610
1171
  'primer/responsive-widths': true,
1611
1172
  'primer/spacing': true,
1612
1173
  'primer/typography': true,
1613
- 'primer/utilities': null,
1614
1174
  'primer/no-display-colors': true,
1615
1175
  'property-no-unknown': [
1616
1176
  true,
@@ -1662,10 +1222,8 @@ var index = {
1662
1222
  'length-zero-no-unit': null,
1663
1223
  'selector-max-type': null,
1664
1224
  'primer/colors': null,
1665
- 'primer/borders': null,
1666
1225
  'primer/typography': null,
1667
1226
  'primer/box-shadow': null,
1668
- 'primer/utilities': null,
1669
1227
  },
1670
1228
  },
1671
1229
  {
@@ -1690,7 +1248,6 @@ var index = {
1690
1248
  },
1691
1249
  {
1692
1250
  files: ['**/*.module.css'],
1693
- plugins: ['stylelint-css-modules-no-global-scoped-selector'],
1694
1251
  rules: {
1695
1252
  'property-no-unknown': [
1696
1253
  true,
@@ -1715,12 +1272,9 @@ var index = {
1715
1272
  ignoreFunctions: ['global'],
1716
1273
  },
1717
1274
  ],
1718
- 'css-modules/no-global-scoped-selector': true,
1719
1275
  // temporarily disabiling Primer plugins while we work on upgrades https://github.com/github/primer/issues/3165
1720
- 'primer/borders': null,
1721
1276
  'primer/typography': null,
1722
1277
  'primer/box-shadow': null,
1723
- 'primer/utilities': null,
1724
1278
  },
1725
1279
  },
1726
1280
  ],