@primer/stylelint-config 13.0.1-rc.5358628 → 13.0.1-rc.6de0604
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.cjs +57 -112
- package/dist/index.mjs +57 -112
- package/package.json +1 -1
- package/plugins/borders.js +16 -28
- package/plugins/box-shadow.js +15 -24
- package/plugins/lib/variable-rules.js +1 -7
- package/plugins/spacing.js +16 -30
- package/plugins/typography.js +9 -23
package/dist/index.cjs
CHANGED
|
@@ -292,7 +292,7 @@ for (const variable of variables$2) {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
/** @type {import('stylelint').Rule} */
|
|
295
|
-
const ruleFunction$3 =
|
|
295
|
+
const ruleFunction$3 = primary => {
|
|
296
296
|
return (root, result) => {
|
|
297
297
|
const validOptions = validateOptions$3(result, ruleName$5, {
|
|
298
298
|
actual: primary,
|
|
@@ -308,8 +308,6 @@ const ruleFunction$3 = (primary, secondaryOptions, context) => {
|
|
|
308
308
|
if (/^border(-(top|right|bottom|left|block-start|block-end|inline-start|inline-end))?-color$/.test(prop)) return
|
|
309
309
|
if (valueList$1.some(valueToIgnore => value.includes(valueToIgnore))) return
|
|
310
310
|
|
|
311
|
-
const problems = [];
|
|
312
|
-
|
|
313
311
|
const parsedValue = walkGroups$1(valueParser(value), node => {
|
|
314
312
|
const checkForVariable = (vars, nodeValue) =>
|
|
315
313
|
vars.some(variable =>
|
|
@@ -387,36 +385,26 @@ const ruleFunction$3 = (primary, secondaryOptions, context) => {
|
|
|
387
385
|
variable.values.includes(node.value.replace('-', '')),
|
|
388
386
|
);
|
|
389
387
|
const fixable = replacement && valueUnit && !valueUnit.number.includes('-');
|
|
390
|
-
|
|
391
|
-
if (fixable
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
396
|
-
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
397
|
-
message: messages$5.rejected(node.value, replacement, prop),
|
|
398
|
-
});
|
|
388
|
+
let fix = undefined;
|
|
389
|
+
if (fixable) {
|
|
390
|
+
fix = () => {
|
|
391
|
+
node.value = node.value.replace(node.value, `var(${replacement['name']})`);
|
|
392
|
+
};
|
|
399
393
|
}
|
|
394
|
+
report$3({
|
|
395
|
+
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
396
|
+
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
397
|
+
message: messages$5.rejected(node.value, replacement, prop),
|
|
398
|
+
node: declNode,
|
|
399
|
+
result,
|
|
400
|
+
ruleName: ruleName$5,
|
|
401
|
+
fix,
|
|
402
|
+
});
|
|
400
403
|
|
|
401
404
|
return
|
|
402
405
|
});
|
|
403
406
|
|
|
404
|
-
|
|
405
|
-
declNode.value = parsedValue.toString();
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (problems.length) {
|
|
409
|
-
for (const err of problems) {
|
|
410
|
-
report$3({
|
|
411
|
-
index: err.index,
|
|
412
|
-
endIndex: err.endIndex,
|
|
413
|
-
message: err.message,
|
|
414
|
-
node: declNode,
|
|
415
|
-
result,
|
|
416
|
-
ruleName: ruleName$5,
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
}
|
|
407
|
+
declNode.value = parsedValue.toString();
|
|
420
408
|
});
|
|
421
409
|
}
|
|
422
410
|
};
|
|
@@ -459,7 +447,7 @@ for (const variable of variables$1) {
|
|
|
459
447
|
}
|
|
460
448
|
|
|
461
449
|
/** @type {import('stylelint').Rule} */
|
|
462
|
-
const ruleFunction$2 =
|
|
450
|
+
const ruleFunction$2 = primary => {
|
|
463
451
|
return (root, result) => {
|
|
464
452
|
const validOptions = validateOptions$2(result, ruleName$4, {
|
|
465
453
|
actual: primary,
|
|
@@ -476,8 +464,6 @@ const ruleFunction$2 = (primary, secondaryOptions, context) => {
|
|
|
476
464
|
|
|
477
465
|
if (value === 'none') return
|
|
478
466
|
|
|
479
|
-
const problems = [];
|
|
480
|
-
|
|
481
467
|
const checkForVariable = (vars, nodeValue) => {
|
|
482
468
|
return vars.some(variable =>
|
|
483
469
|
new RegExp(`${variable['name'].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(nodeValue),
|
|
@@ -489,29 +475,22 @@ const ruleFunction$2 = (primary, secondaryOptions, context) => {
|
|
|
489
475
|
}
|
|
490
476
|
|
|
491
477
|
const replacement = validValues.find(variable => variable.values.includes(value));
|
|
492
|
-
|
|
493
|
-
if (replacement
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
index: declarationValueIndex(declNode),
|
|
498
|
-
endIndex: declarationValueIndex(declNode) + value.length,
|
|
499
|
-
message: messages$4.rejected(value, replacement),
|
|
500
|
-
});
|
|
478
|
+
let fix = undefined;
|
|
479
|
+
if (replacement) {
|
|
480
|
+
fix = () => {
|
|
481
|
+
declNode.value = value.replace(value, `var(${replacement['name']})`);
|
|
482
|
+
};
|
|
501
483
|
}
|
|
502
484
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
}
|
|
485
|
+
report$2({
|
|
486
|
+
index: declarationValueIndex(declNode),
|
|
487
|
+
endIndex: declarationValueIndex(declNode) + value.length,
|
|
488
|
+
message: messages$4.rejected(value, replacement),
|
|
489
|
+
node: declNode,
|
|
490
|
+
result,
|
|
491
|
+
ruleName: ruleName$4,
|
|
492
|
+
fix,
|
|
493
|
+
});
|
|
515
494
|
});
|
|
516
495
|
}
|
|
517
496
|
};
|
|
@@ -783,7 +762,7 @@ function createVariableRule(ruleName, rules, url) {
|
|
|
783
762
|
|
|
784
763
|
// The stylelint docs suggest respecting a "disableFix" rule option that
|
|
785
764
|
// overrides the "global" context.fix (--fix) linting option.
|
|
786
|
-
const {
|
|
765
|
+
const {disableFix} = options;
|
|
787
766
|
const fixEnabled = context && context.fix && !disableFix;
|
|
788
767
|
const seen = new WeakMap();
|
|
789
768
|
|
|
@@ -799,16 +778,10 @@ function createVariableRule(ruleName, rules, url) {
|
|
|
799
778
|
const validated = validate(decl);
|
|
800
779
|
const {valid, fixable, replacement, errors} = validated;
|
|
801
780
|
if (valid) {
|
|
802
|
-
// eslint-disable-next-line no-console
|
|
803
|
-
if (verbose) console.warn(`valid: "${decl.toString()}" in: "${rule.selector}"`);
|
|
804
781
|
return
|
|
805
782
|
} else if (fixEnabled && fixable) {
|
|
806
|
-
// eslint-disable-next-line no-console
|
|
807
|
-
if (verbose) console.warn(` fixed: ${replacement}`);
|
|
808
783
|
decl.value = replacement;
|
|
809
784
|
} else {
|
|
810
|
-
// eslint-disable-next-line no-console
|
|
811
|
-
if (verbose) console.warn(` ${errors.length} error(s)`);
|
|
812
785
|
for (const error of errors) {
|
|
813
786
|
const message = stylelint.utils
|
|
814
787
|
.ruleMessages(ruleName, {
|
|
@@ -1008,7 +981,7 @@ for (const size of sizes) {
|
|
|
1008
981
|
}
|
|
1009
982
|
|
|
1010
983
|
/** @type {import('stylelint').Rule} */
|
|
1011
|
-
const ruleFunction$1 =
|
|
984
|
+
const ruleFunction$1 = primary => {
|
|
1012
985
|
return (root, result) => {
|
|
1013
986
|
const validOptions = validateOptions$1(result, ruleName$2, {
|
|
1014
987
|
actual: primary,
|
|
@@ -1023,8 +996,6 @@ const ruleFunction$1 = (primary, secondaryOptions, context) => {
|
|
|
1023
996
|
if (!propList$1.some(spacingProp => prop.startsWith(spacingProp))) return
|
|
1024
997
|
if (valueList.some(valueToIgnore => value.includes(valueToIgnore))) return
|
|
1025
998
|
|
|
1026
|
-
const problems = [];
|
|
1027
|
-
|
|
1028
999
|
const parsedValue = walkGroups$1(valueParser(value), node => {
|
|
1029
1000
|
// Only check word types. https://github.com/TrySound/postcss-value-parser#word
|
|
1030
1001
|
if (node.type !== 'word') {
|
|
@@ -1058,36 +1029,24 @@ const ruleFunction$1 = (primary, secondaryOptions, context) => {
|
|
|
1058
1029
|
|
|
1059
1030
|
const replacement = sizes.find(variable => variable.values.includes(node.value.replace('-', '')));
|
|
1060
1031
|
const fixable = replacement && valueUnit && !valueUnit.number.includes('-');
|
|
1061
|
-
|
|
1062
|
-
if (fixable
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
1067
|
-
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
1068
|
-
message: messages$2.rejected(node.value, replacement),
|
|
1069
|
-
});
|
|
1032
|
+
let fix = undefined;
|
|
1033
|
+
if (fixable) {
|
|
1034
|
+
fix = () => {
|
|
1035
|
+
node.value = node.value.replace(node.value, `var(${replacement['name']})`);
|
|
1036
|
+
};
|
|
1070
1037
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1038
|
+
report$1({
|
|
1039
|
+
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
1040
|
+
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
1041
|
+
message: messages$2.rejected(node.value, replacement),
|
|
1042
|
+
node: declNode,
|
|
1043
|
+
result,
|
|
1044
|
+
ruleName: ruleName$2,
|
|
1045
|
+
fix,
|
|
1046
|
+
});
|
|
1073
1047
|
});
|
|
1074
1048
|
|
|
1075
|
-
|
|
1076
|
-
declNode.value = parsedValue.toString();
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
if (problems.length) {
|
|
1080
|
-
for (const err of problems) {
|
|
1081
|
-
report$1({
|
|
1082
|
-
index: err.index,
|
|
1083
|
-
endIndex: err.endIndex,
|
|
1084
|
-
message: err.message,
|
|
1085
|
-
node: declNode,
|
|
1086
|
-
result,
|
|
1087
|
-
ruleName: ruleName$2,
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1049
|
+
declNode.value = parsedValue.toString();
|
|
1091
1050
|
});
|
|
1092
1051
|
}
|
|
1093
1052
|
};
|
|
@@ -1185,8 +1144,6 @@ const ruleFunction = primary => {
|
|
|
1185
1144
|
|
|
1186
1145
|
if (!propList.some(typographyProp => prop === typographyProp)) return
|
|
1187
1146
|
|
|
1188
|
-
const problems = [];
|
|
1189
|
-
|
|
1190
1147
|
const checkForVariable = (vars, nodeValue) =>
|
|
1191
1148
|
vars.some(variable =>
|
|
1192
1149
|
new RegExp(`${variable['name'].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(nodeValue),
|
|
@@ -1244,34 +1201,22 @@ const ruleFunction = primary => {
|
|
|
1244
1201
|
};
|
|
1245
1202
|
const replacement = getReplacements();
|
|
1246
1203
|
const fixable = replacement && !replacement.length;
|
|
1247
|
-
let
|
|
1204
|
+
let fix = undefined;
|
|
1248
1205
|
if (fixable) {
|
|
1249
|
-
|
|
1206
|
+
fix = () => {
|
|
1207
|
+
declNode.value = value.replace(value, `var(${replacement['name']})`);
|
|
1208
|
+
};
|
|
1250
1209
|
}
|
|
1251
1210
|
|
|
1252
|
-
|
|
1211
|
+
report({
|
|
1253
1212
|
index: declarationValueIndex(declNode),
|
|
1254
1213
|
endIndex: declarationValueIndex(declNode) + value.length,
|
|
1255
1214
|
message: messages$1.rejected(value, replacement, prop),
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1215
|
+
node: declNode,
|
|
1216
|
+
result,
|
|
1217
|
+
ruleName: ruleName$1,
|
|
1218
|
+
fix,
|
|
1260
1219
|
});
|
|
1261
|
-
|
|
1262
|
-
if (problems.length) {
|
|
1263
|
-
for (const err of problems) {
|
|
1264
|
-
report({
|
|
1265
|
-
index: err.index,
|
|
1266
|
-
endIndex: err.endIndex,
|
|
1267
|
-
message: err.message,
|
|
1268
|
-
node: declNode,
|
|
1269
|
-
result,
|
|
1270
|
-
ruleName: ruleName$1,
|
|
1271
|
-
fix: err.fix,
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
1220
|
});
|
|
1276
1221
|
}
|
|
1277
1222
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -289,7 +289,7 @@ for (const variable of variables$2) {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
/** @type {import('stylelint').Rule} */
|
|
292
|
-
const ruleFunction$3 =
|
|
292
|
+
const ruleFunction$3 = primary => {
|
|
293
293
|
return (root, result) => {
|
|
294
294
|
const validOptions = validateOptions$3(result, ruleName$5, {
|
|
295
295
|
actual: primary,
|
|
@@ -305,8 +305,6 @@ const ruleFunction$3 = (primary, secondaryOptions, context) => {
|
|
|
305
305
|
if (/^border(-(top|right|bottom|left|block-start|block-end|inline-start|inline-end))?-color$/.test(prop)) return
|
|
306
306
|
if (valueList$1.some(valueToIgnore => value.includes(valueToIgnore))) return
|
|
307
307
|
|
|
308
|
-
const problems = [];
|
|
309
|
-
|
|
310
308
|
const parsedValue = walkGroups$1(valueParser(value), node => {
|
|
311
309
|
const checkForVariable = (vars, nodeValue) =>
|
|
312
310
|
vars.some(variable =>
|
|
@@ -384,36 +382,26 @@ const ruleFunction$3 = (primary, secondaryOptions, context) => {
|
|
|
384
382
|
variable.values.includes(node.value.replace('-', '')),
|
|
385
383
|
);
|
|
386
384
|
const fixable = replacement && valueUnit && !valueUnit.number.includes('-');
|
|
387
|
-
|
|
388
|
-
if (fixable
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
393
|
-
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
394
|
-
message: messages$5.rejected(node.value, replacement, prop),
|
|
395
|
-
});
|
|
385
|
+
let fix = undefined;
|
|
386
|
+
if (fixable) {
|
|
387
|
+
fix = () => {
|
|
388
|
+
node.value = node.value.replace(node.value, `var(${replacement['name']})`);
|
|
389
|
+
};
|
|
396
390
|
}
|
|
391
|
+
report$3({
|
|
392
|
+
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
393
|
+
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
394
|
+
message: messages$5.rejected(node.value, replacement, prop),
|
|
395
|
+
node: declNode,
|
|
396
|
+
result,
|
|
397
|
+
ruleName: ruleName$5,
|
|
398
|
+
fix,
|
|
399
|
+
});
|
|
397
400
|
|
|
398
401
|
return
|
|
399
402
|
});
|
|
400
403
|
|
|
401
|
-
|
|
402
|
-
declNode.value = parsedValue.toString();
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (problems.length) {
|
|
406
|
-
for (const err of problems) {
|
|
407
|
-
report$3({
|
|
408
|
-
index: err.index,
|
|
409
|
-
endIndex: err.endIndex,
|
|
410
|
-
message: err.message,
|
|
411
|
-
node: declNode,
|
|
412
|
-
result,
|
|
413
|
-
ruleName: ruleName$5,
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}
|
|
404
|
+
declNode.value = parsedValue.toString();
|
|
417
405
|
});
|
|
418
406
|
}
|
|
419
407
|
};
|
|
@@ -456,7 +444,7 @@ for (const variable of variables$1) {
|
|
|
456
444
|
}
|
|
457
445
|
|
|
458
446
|
/** @type {import('stylelint').Rule} */
|
|
459
|
-
const ruleFunction$2 =
|
|
447
|
+
const ruleFunction$2 = primary => {
|
|
460
448
|
return (root, result) => {
|
|
461
449
|
const validOptions = validateOptions$2(result, ruleName$4, {
|
|
462
450
|
actual: primary,
|
|
@@ -473,8 +461,6 @@ const ruleFunction$2 = (primary, secondaryOptions, context) => {
|
|
|
473
461
|
|
|
474
462
|
if (value === 'none') return
|
|
475
463
|
|
|
476
|
-
const problems = [];
|
|
477
|
-
|
|
478
464
|
const checkForVariable = (vars, nodeValue) => {
|
|
479
465
|
return vars.some(variable =>
|
|
480
466
|
new RegExp(`${variable['name'].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(nodeValue),
|
|
@@ -486,29 +472,22 @@ const ruleFunction$2 = (primary, secondaryOptions, context) => {
|
|
|
486
472
|
}
|
|
487
473
|
|
|
488
474
|
const replacement = validValues.find(variable => variable.values.includes(value));
|
|
489
|
-
|
|
490
|
-
if (replacement
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
index: declarationValueIndex(declNode),
|
|
495
|
-
endIndex: declarationValueIndex(declNode) + value.length,
|
|
496
|
-
message: messages$4.rejected(value, replacement),
|
|
497
|
-
});
|
|
475
|
+
let fix = undefined;
|
|
476
|
+
if (replacement) {
|
|
477
|
+
fix = () => {
|
|
478
|
+
declNode.value = value.replace(value, `var(${replacement['name']})`);
|
|
479
|
+
};
|
|
498
480
|
}
|
|
499
481
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
}
|
|
482
|
+
report$2({
|
|
483
|
+
index: declarationValueIndex(declNode),
|
|
484
|
+
endIndex: declarationValueIndex(declNode) + value.length,
|
|
485
|
+
message: messages$4.rejected(value, replacement),
|
|
486
|
+
node: declNode,
|
|
487
|
+
result,
|
|
488
|
+
ruleName: ruleName$4,
|
|
489
|
+
fix,
|
|
490
|
+
});
|
|
512
491
|
});
|
|
513
492
|
}
|
|
514
493
|
};
|
|
@@ -780,7 +759,7 @@ function createVariableRule(ruleName, rules, url) {
|
|
|
780
759
|
|
|
781
760
|
// The stylelint docs suggest respecting a "disableFix" rule option that
|
|
782
761
|
// overrides the "global" context.fix (--fix) linting option.
|
|
783
|
-
const {
|
|
762
|
+
const {disableFix} = options;
|
|
784
763
|
const fixEnabled = context && context.fix && !disableFix;
|
|
785
764
|
const seen = new WeakMap();
|
|
786
765
|
|
|
@@ -796,16 +775,10 @@ function createVariableRule(ruleName, rules, url) {
|
|
|
796
775
|
const validated = validate(decl);
|
|
797
776
|
const {valid, fixable, replacement, errors} = validated;
|
|
798
777
|
if (valid) {
|
|
799
|
-
// eslint-disable-next-line no-console
|
|
800
|
-
if (verbose) console.warn(`valid: "${decl.toString()}" in: "${rule.selector}"`);
|
|
801
778
|
return
|
|
802
779
|
} else if (fixEnabled && fixable) {
|
|
803
|
-
// eslint-disable-next-line no-console
|
|
804
|
-
if (verbose) console.warn(` fixed: ${replacement}`);
|
|
805
780
|
decl.value = replacement;
|
|
806
781
|
} else {
|
|
807
|
-
// eslint-disable-next-line no-console
|
|
808
|
-
if (verbose) console.warn(` ${errors.length} error(s)`);
|
|
809
782
|
for (const error of errors) {
|
|
810
783
|
const message = stylelint.utils
|
|
811
784
|
.ruleMessages(ruleName, {
|
|
@@ -1005,7 +978,7 @@ for (const size of sizes) {
|
|
|
1005
978
|
}
|
|
1006
979
|
|
|
1007
980
|
/** @type {import('stylelint').Rule} */
|
|
1008
|
-
const ruleFunction$1 =
|
|
981
|
+
const ruleFunction$1 = primary => {
|
|
1009
982
|
return (root, result) => {
|
|
1010
983
|
const validOptions = validateOptions$1(result, ruleName$2, {
|
|
1011
984
|
actual: primary,
|
|
@@ -1020,8 +993,6 @@ const ruleFunction$1 = (primary, secondaryOptions, context) => {
|
|
|
1020
993
|
if (!propList$1.some(spacingProp => prop.startsWith(spacingProp))) return
|
|
1021
994
|
if (valueList.some(valueToIgnore => value.includes(valueToIgnore))) return
|
|
1022
995
|
|
|
1023
|
-
const problems = [];
|
|
1024
|
-
|
|
1025
996
|
const parsedValue = walkGroups$1(valueParser(value), node => {
|
|
1026
997
|
// Only check word types. https://github.com/TrySound/postcss-value-parser#word
|
|
1027
998
|
if (node.type !== 'word') {
|
|
@@ -1055,36 +1026,24 @@ const ruleFunction$1 = (primary, secondaryOptions, context) => {
|
|
|
1055
1026
|
|
|
1056
1027
|
const replacement = sizes.find(variable => variable.values.includes(node.value.replace('-', '')));
|
|
1057
1028
|
const fixable = replacement && valueUnit && !valueUnit.number.includes('-');
|
|
1058
|
-
|
|
1059
|
-
if (fixable
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
1064
|
-
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
1065
|
-
message: messages$2.rejected(node.value, replacement),
|
|
1066
|
-
});
|
|
1029
|
+
let fix = undefined;
|
|
1030
|
+
if (fixable) {
|
|
1031
|
+
fix = () => {
|
|
1032
|
+
node.value = node.value.replace(node.value, `var(${replacement['name']})`);
|
|
1033
|
+
};
|
|
1067
1034
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1035
|
+
report$1({
|
|
1036
|
+
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
1037
|
+
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
1038
|
+
message: messages$2.rejected(node.value, replacement),
|
|
1039
|
+
node: declNode,
|
|
1040
|
+
result,
|
|
1041
|
+
ruleName: ruleName$2,
|
|
1042
|
+
fix,
|
|
1043
|
+
});
|
|
1070
1044
|
});
|
|
1071
1045
|
|
|
1072
|
-
|
|
1073
|
-
declNode.value = parsedValue.toString();
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
if (problems.length) {
|
|
1077
|
-
for (const err of problems) {
|
|
1078
|
-
report$1({
|
|
1079
|
-
index: err.index,
|
|
1080
|
-
endIndex: err.endIndex,
|
|
1081
|
-
message: err.message,
|
|
1082
|
-
node: declNode,
|
|
1083
|
-
result,
|
|
1084
|
-
ruleName: ruleName$2,
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1046
|
+
declNode.value = parsedValue.toString();
|
|
1088
1047
|
});
|
|
1089
1048
|
}
|
|
1090
1049
|
};
|
|
@@ -1182,8 +1141,6 @@ const ruleFunction = primary => {
|
|
|
1182
1141
|
|
|
1183
1142
|
if (!propList.some(typographyProp => prop === typographyProp)) return
|
|
1184
1143
|
|
|
1185
|
-
const problems = [];
|
|
1186
|
-
|
|
1187
1144
|
const checkForVariable = (vars, nodeValue) =>
|
|
1188
1145
|
vars.some(variable =>
|
|
1189
1146
|
new RegExp(`${variable['name'].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(nodeValue),
|
|
@@ -1241,34 +1198,22 @@ const ruleFunction = primary => {
|
|
|
1241
1198
|
};
|
|
1242
1199
|
const replacement = getReplacements();
|
|
1243
1200
|
const fixable = replacement && !replacement.length;
|
|
1244
|
-
let
|
|
1201
|
+
let fix = undefined;
|
|
1245
1202
|
if (fixable) {
|
|
1246
|
-
|
|
1203
|
+
fix = () => {
|
|
1204
|
+
declNode.value = value.replace(value, `var(${replacement['name']})`);
|
|
1205
|
+
};
|
|
1247
1206
|
}
|
|
1248
1207
|
|
|
1249
|
-
|
|
1208
|
+
report({
|
|
1250
1209
|
index: declarationValueIndex(declNode),
|
|
1251
1210
|
endIndex: declarationValueIndex(declNode) + value.length,
|
|
1252
1211
|
message: messages$1.rejected(value, replacement, prop),
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1212
|
+
node: declNode,
|
|
1213
|
+
result,
|
|
1214
|
+
ruleName: ruleName$1,
|
|
1215
|
+
fix,
|
|
1257
1216
|
});
|
|
1258
|
-
|
|
1259
|
-
if (problems.length) {
|
|
1260
|
-
for (const err of problems) {
|
|
1261
|
-
report({
|
|
1262
|
-
index: err.index,
|
|
1263
|
-
endIndex: err.endIndex,
|
|
1264
|
-
message: err.message,
|
|
1265
|
-
node: declNode,
|
|
1266
|
-
result,
|
|
1267
|
-
ruleName: ruleName$1,
|
|
1268
|
-
fix: err.fix,
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
1217
|
});
|
|
1273
1218
|
}
|
|
1274
1219
|
};
|
package/package.json
CHANGED
package/plugins/borders.js
CHANGED
|
@@ -59,7 +59,7 @@ for (const variable of variables) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/** @type {import('stylelint').Rule} */
|
|
62
|
-
const ruleFunction =
|
|
62
|
+
const ruleFunction = primary => {
|
|
63
63
|
return (root, result) => {
|
|
64
64
|
const validOptions = validateOptions(result, ruleName, {
|
|
65
65
|
actual: primary,
|
|
@@ -75,8 +75,6 @@ const ruleFunction = (primary, secondaryOptions, context) => {
|
|
|
75
75
|
if (/^border(-(top|right|bottom|left|block-start|block-end|inline-start|inline-end))?-color$/.test(prop)) return
|
|
76
76
|
if (valueList.some(valueToIgnore => value.includes(valueToIgnore))) return
|
|
77
77
|
|
|
78
|
-
const problems = []
|
|
79
|
-
|
|
80
78
|
const parsedValue = walkGroups(valueParser(value), node => {
|
|
81
79
|
const checkForVariable = (vars, nodeValue) =>
|
|
82
80
|
vars.some(variable =>
|
|
@@ -154,36 +152,26 @@ const ruleFunction = (primary, secondaryOptions, context) => {
|
|
|
154
152
|
variable.values.includes(node.value.replace('-', '')),
|
|
155
153
|
)
|
|
156
154
|
const fixable = replacement && valueUnit && !valueUnit.number.includes('-')
|
|
157
|
-
|
|
158
|
-
if (fixable
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
163
|
-
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
164
|
-
message: messages.rejected(node.value, replacement, prop),
|
|
165
|
-
})
|
|
155
|
+
let fix = undefined
|
|
156
|
+
if (fixable) {
|
|
157
|
+
fix = () => {
|
|
158
|
+
node.value = node.value.replace(node.value, `var(${replacement['name']})`)
|
|
159
|
+
}
|
|
166
160
|
}
|
|
161
|
+
report({
|
|
162
|
+
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
163
|
+
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
164
|
+
message: messages.rejected(node.value, replacement, prop),
|
|
165
|
+
node: declNode,
|
|
166
|
+
result,
|
|
167
|
+
ruleName,
|
|
168
|
+
fix,
|
|
169
|
+
})
|
|
167
170
|
|
|
168
171
|
return
|
|
169
172
|
})
|
|
170
173
|
|
|
171
|
-
|
|
172
|
-
declNode.value = parsedValue.toString()
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (problems.length) {
|
|
176
|
-
for (const err of problems) {
|
|
177
|
-
report({
|
|
178
|
-
index: err.index,
|
|
179
|
-
endIndex: err.endIndex,
|
|
180
|
-
message: err.message,
|
|
181
|
-
node: declNode,
|
|
182
|
-
result,
|
|
183
|
-
ruleName,
|
|
184
|
-
})
|
|
185
|
-
}
|
|
186
|
-
}
|
|
174
|
+
declNode.value = parsedValue.toString()
|
|
187
175
|
})
|
|
188
176
|
}
|
|
189
177
|
}
|
package/plugins/box-shadow.js
CHANGED
|
@@ -32,7 +32,7 @@ for (const variable of variables) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** @type {import('stylelint').Rule} */
|
|
35
|
-
const ruleFunction =
|
|
35
|
+
const ruleFunction = primary => {
|
|
36
36
|
return (root, result) => {
|
|
37
37
|
const validOptions = validateOptions(result, ruleName, {
|
|
38
38
|
actual: primary,
|
|
@@ -49,8 +49,6 @@ const ruleFunction = (primary, secondaryOptions, context) => {
|
|
|
49
49
|
|
|
50
50
|
if (value === 'none') return
|
|
51
51
|
|
|
52
|
-
const problems = []
|
|
53
|
-
|
|
54
52
|
const checkForVariable = (vars, nodeValue) => {
|
|
55
53
|
return vars.some(variable =>
|
|
56
54
|
new RegExp(`${variable['name'].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(nodeValue),
|
|
@@ -62,29 +60,22 @@ const ruleFunction = (primary, secondaryOptions, context) => {
|
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
const replacement = validValues.find(variable => variable.values.includes(value))
|
|
65
|
-
|
|
66
|
-
if (replacement
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
problems.push({
|
|
70
|
-
index: declarationValueIndex(declNode),
|
|
71
|
-
endIndex: declarationValueIndex(declNode) + value.length,
|
|
72
|
-
message: messages.rejected(value, replacement),
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (problems.length) {
|
|
77
|
-
for (const err of problems) {
|
|
78
|
-
report({
|
|
79
|
-
index: err.index,
|
|
80
|
-
endIndex: err.endIndex,
|
|
81
|
-
message: err.message,
|
|
82
|
-
node: declNode,
|
|
83
|
-
result,
|
|
84
|
-
ruleName,
|
|
85
|
-
})
|
|
63
|
+
let fix = undefined
|
|
64
|
+
if (replacement) {
|
|
65
|
+
fix = () => {
|
|
66
|
+
declNode.value = value.replace(value, `var(${replacement['name']})`)
|
|
86
67
|
}
|
|
87
68
|
}
|
|
69
|
+
|
|
70
|
+
report({
|
|
71
|
+
index: declarationValueIndex(declNode),
|
|
72
|
+
endIndex: declarationValueIndex(declNode) + value.length,
|
|
73
|
+
message: messages.rejected(value, replacement),
|
|
74
|
+
node: declNode,
|
|
75
|
+
result,
|
|
76
|
+
ruleName,
|
|
77
|
+
fix,
|
|
78
|
+
})
|
|
88
79
|
})
|
|
89
80
|
}
|
|
90
81
|
}
|
|
@@ -30,7 +30,7 @@ export function createVariableRule(ruleName, rules, url) {
|
|
|
30
30
|
|
|
31
31
|
// The stylelint docs suggest respecting a "disableFix" rule option that
|
|
32
32
|
// overrides the "global" context.fix (--fix) linting option.
|
|
33
|
-
const {
|
|
33
|
+
const {disableFix} = options
|
|
34
34
|
const fixEnabled = context && context.fix && !disableFix
|
|
35
35
|
const seen = new WeakMap()
|
|
36
36
|
|
|
@@ -46,16 +46,10 @@ export function createVariableRule(ruleName, rules, url) {
|
|
|
46
46
|
const validated = validate(decl)
|
|
47
47
|
const {valid, fixable, replacement, errors} = validated
|
|
48
48
|
if (valid) {
|
|
49
|
-
// eslint-disable-next-line no-console
|
|
50
|
-
if (verbose) console.warn(`valid: "${decl.toString()}" in: "${rule.selector}"`)
|
|
51
49
|
return
|
|
52
50
|
} else if (fixEnabled && fixable) {
|
|
53
|
-
// eslint-disable-next-line no-console
|
|
54
|
-
if (verbose) console.warn(` fixed: ${replacement}`)
|
|
55
51
|
decl.value = replacement
|
|
56
52
|
} else {
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
if (verbose) console.warn(` ${errors.length} error(s)`)
|
|
59
53
|
for (const error of errors) {
|
|
60
54
|
const message = stylelint.utils
|
|
61
55
|
.ruleMessages(ruleName, {
|
package/plugins/spacing.js
CHANGED
|
@@ -37,7 +37,7 @@ for (const size of sizes) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** @type {import('stylelint').Rule} */
|
|
40
|
-
const ruleFunction =
|
|
40
|
+
const ruleFunction = primary => {
|
|
41
41
|
return (root, result) => {
|
|
42
42
|
const validOptions = validateOptions(result, ruleName, {
|
|
43
43
|
actual: primary,
|
|
@@ -52,8 +52,6 @@ const ruleFunction = (primary, secondaryOptions, context) => {
|
|
|
52
52
|
if (!propList.some(spacingProp => prop.startsWith(spacingProp))) return
|
|
53
53
|
if (valueList.some(valueToIgnore => value.includes(valueToIgnore))) return
|
|
54
54
|
|
|
55
|
-
const problems = []
|
|
56
|
-
|
|
57
55
|
const parsedValue = walkGroups(valueParser(value), node => {
|
|
58
56
|
// Only check word types. https://github.com/TrySound/postcss-value-parser#word
|
|
59
57
|
if (node.type !== 'word') {
|
|
@@ -87,36 +85,24 @@ const ruleFunction = (primary, secondaryOptions, context) => {
|
|
|
87
85
|
|
|
88
86
|
const replacement = sizes.find(variable => variable.values.includes(node.value.replace('-', '')))
|
|
89
87
|
const fixable = replacement && valueUnit && !valueUnit.number.includes('-')
|
|
90
|
-
|
|
91
|
-
if (fixable
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
96
|
-
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
97
|
-
message: messages.rejected(node.value, replacement),
|
|
98
|
-
})
|
|
88
|
+
let fix = undefined
|
|
89
|
+
if (fixable) {
|
|
90
|
+
fix = () => {
|
|
91
|
+
node.value = node.value.replace(node.value, `var(${replacement['name']})`)
|
|
92
|
+
}
|
|
99
93
|
}
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
report({
|
|
95
|
+
index: declarationValueIndex(declNode) + node.sourceIndex,
|
|
96
|
+
endIndex: declarationValueIndex(declNode) + node.sourceIndex + node.value.length,
|
|
97
|
+
message: messages.rejected(node.value, replacement),
|
|
98
|
+
node: declNode,
|
|
99
|
+
result,
|
|
100
|
+
ruleName,
|
|
101
|
+
fix,
|
|
102
|
+
})
|
|
102
103
|
})
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
declNode.value = parsedValue.toString()
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (problems.length) {
|
|
109
|
-
for (const err of problems) {
|
|
110
|
-
report({
|
|
111
|
-
index: err.index,
|
|
112
|
-
endIndex: err.endIndex,
|
|
113
|
-
message: err.message,
|
|
114
|
-
node: declNode,
|
|
115
|
-
result,
|
|
116
|
-
ruleName,
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
}
|
|
105
|
+
declNode.value = parsedValue.toString()
|
|
120
106
|
})
|
|
121
107
|
}
|
|
122
108
|
}
|
package/plugins/typography.js
CHANGED
|
@@ -87,8 +87,6 @@ const ruleFunction = primary => {
|
|
|
87
87
|
|
|
88
88
|
if (!propList.some(typographyProp => prop === typographyProp)) return
|
|
89
89
|
|
|
90
|
-
const problems = []
|
|
91
|
-
|
|
92
90
|
const checkForVariable = (vars, nodeValue) =>
|
|
93
91
|
vars.some(variable =>
|
|
94
92
|
new RegExp(`${variable['name'].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(nodeValue),
|
|
@@ -146,34 +144,22 @@ const ruleFunction = primary => {
|
|
|
146
144
|
}
|
|
147
145
|
const replacement = getReplacements()
|
|
148
146
|
const fixable = replacement && !replacement.length
|
|
149
|
-
let
|
|
147
|
+
let fix = undefined
|
|
150
148
|
if (fixable) {
|
|
151
|
-
|
|
149
|
+
fix = () => {
|
|
150
|
+
declNode.value = value.replace(value, `var(${replacement['name']})`)
|
|
151
|
+
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
report({
|
|
155
155
|
index: declarationValueIndex(declNode),
|
|
156
156
|
endIndex: declarationValueIndex(declNode) + value.length,
|
|
157
157
|
message: messages.rejected(value, replacement, prop),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
node: declNode,
|
|
159
|
+
result,
|
|
160
|
+
ruleName,
|
|
161
|
+
fix,
|
|
162
162
|
})
|
|
163
|
-
|
|
164
|
-
if (problems.length) {
|
|
165
|
-
for (const err of problems) {
|
|
166
|
-
report({
|
|
167
|
-
index: err.index,
|
|
168
|
-
endIndex: err.endIndex,
|
|
169
|
-
message: err.message,
|
|
170
|
-
node: declNode,
|
|
171
|
-
result,
|
|
172
|
-
ruleName,
|
|
173
|
-
fix: err.fix,
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
163
|
})
|
|
178
164
|
}
|
|
179
165
|
}
|