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