stylelint-config-crisp 1.0.28 → 1.0.30
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/package.json
CHANGED
|
@@ -70,7 +70,33 @@ const ruleFunction = (primaryOption, secondaryOptions = {}, context) => {
|
|
|
70
70
|
|
|
71
71
|
// Convert a string to kebab-case
|
|
72
72
|
function toKebabCase(str) {
|
|
73
|
-
|
|
73
|
+
// Special kebab-case flavor:
|
|
74
|
+
// * `CheckFailures` gets converted to `check-failures`
|
|
75
|
+
// * `CheckSMTPFailures` gets converted to `check-smtp-failures`
|
|
76
|
+
// * `CheckIPsFailures` gets converted to `check-ips-failures`
|
|
77
|
+
// * `MonitoringMailerIPs` gets converted to `monitoring-mailer-ips`
|
|
78
|
+
|
|
79
|
+
return str
|
|
80
|
+
// Handle the transition from multiple uppercase letters to one or \
|
|
81
|
+
// multiple lowercase letters
|
|
82
|
+
.replace(/([A-Z]+)([A-Z]+[a-z]+|(?![a-z]))/g, (match, p1, p2) => {
|
|
83
|
+
// Only one lowercase letter?
|
|
84
|
+
if (p2.length === 2 && /[a-z]/.test(p2.slice(1))) {
|
|
85
|
+
// Make one group (this ensures `IPs` gets converted to `ips` \
|
|
86
|
+
// and not `i-ps`)
|
|
87
|
+
return `${p1}${p2}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Make two different groups
|
|
91
|
+
return `${p1}-${p2}`;
|
|
92
|
+
})
|
|
93
|
+
// Insert a hyphen between lowercase to uppercase transitions
|
|
94
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
95
|
+
// Replace spaces and multiple hyphens with a single hyphen
|
|
96
|
+
.replace(/\s+/g, '-')
|
|
97
|
+
.replace(/-+/g, '-')
|
|
98
|
+
// Convert to lowercase
|
|
99
|
+
.toLowerCase();
|
|
74
100
|
}
|
|
75
101
|
|
|
76
102
|
// Check if a value is a string
|