color-name-list 12.1.0 → 12.2.0
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/.vscode/tasks.json +10 -0
- package/README.md +2 -2
- package/dist/colornames.bestof.csv +17 -16
- package/dist/colornames.bestof.esm.js +1 -1
- package/dist/colornames.bestof.esm.mjs +1 -1
- package/dist/colornames.bestof.html +1 -1
- package/dist/colornames.bestof.json +1 -1
- package/dist/colornames.bestof.min.json +1 -1
- package/dist/colornames.bestof.scss +1 -1
- package/dist/colornames.bestof.umd.js +1 -1
- package/dist/colornames.bestof.xml +42 -38
- package/dist/colornames.bestof.yaml +34 -31
- package/dist/colornames.csv +27 -97
- package/dist/colornames.esm.js +1 -1
- package/dist/colornames.esm.mjs +1 -1
- package/dist/colornames.html +1 -1
- package/dist/colornames.json +1 -1
- package/dist/colornames.min.json +1 -1
- package/dist/colornames.scss +1 -1
- package/dist/colornames.short.csv +9 -15
- package/dist/colornames.short.esm.js +1 -1
- package/dist/colornames.short.esm.mjs +1 -1
- package/dist/colornames.short.html +1 -1
- package/dist/colornames.short.json +1 -1
- package/dist/colornames.short.min.json +1 -1
- package/dist/colornames.short.scss +1 -1
- package/dist/colornames.short.umd.js +1 -1
- package/dist/colornames.short.xml +16 -40
- package/dist/colornames.short.yaml +14 -32
- package/dist/colornames.umd.js +1 -1
- package/dist/colornames.xml +52 -332
- package/dist/colornames.yaml +41 -251
- package/dist/history.json +1 -1
- package/package.json +1 -1
- package/scripts/lib.js +24 -1
- package/src/colornames.csv +29 -99
- package/tests/duplicate-plurals-allowlist.json +7 -0
- package/tests/duplicates.test.js +2 -1
package/package.json
CHANGED
package/scripts/lib.js
CHANGED
|
@@ -131,7 +131,7 @@ export const normalizeNameForDuplicates = (name) => {
|
|
|
131
131
|
* @returns {Array<{norm:string, entries:Array<{name:string, lineNumber?:number}>}>}
|
|
132
132
|
*/
|
|
133
133
|
export const findNearDuplicateNameConflicts = (items, options = {}) => {
|
|
134
|
-
const { allowlist = [] } = options;
|
|
134
|
+
const { allowlist = [], foldPlurals = false, pluralAllowlist = [] } = options;
|
|
135
135
|
|
|
136
136
|
// Normalize allowlist entries so callers can provide raw names or already-normalized keys.
|
|
137
137
|
const allowSet = new Set(
|
|
@@ -148,6 +148,29 @@ export const findNearDuplicateNameConflicts = (items, options = {}) => {
|
|
|
148
148
|
byNorm.get(norm).push({ name: item.name, lineNumber: item.lineNumber });
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
// Optional plural folding: merge keys ending in 's' with their singular if present.
|
|
152
|
+
if (foldPlurals) {
|
|
153
|
+
const pluralAllowSet = new Set(
|
|
154
|
+
(Array.isArray(pluralAllowlist) ? pluralAllowlist : [])
|
|
155
|
+
.filter((v) => typeof v === 'string' && v.trim().length)
|
|
156
|
+
.map((v) => normalizeNameForDuplicates(String(v)))
|
|
157
|
+
);
|
|
158
|
+
// We iterate over a snapshot of keys because we'll mutate the map.
|
|
159
|
+
for (const key of Array.from(byNorm.keys())) {
|
|
160
|
+
if (key.length < 4) continue; // avoid over-aggressive folding for tiny words
|
|
161
|
+
if (!key.endsWith('s')) continue;
|
|
162
|
+
if (key.endsWith('ss')) continue; // glass vs glas, moss vs mos, keep
|
|
163
|
+
if (pluralAllowSet.has(key)) continue; // explicit allow: don't fold
|
|
164
|
+
const singular = key.slice(0, -1);
|
|
165
|
+
if (byNorm.has(singular)) {
|
|
166
|
+
// merge arrays
|
|
167
|
+
const merged = [...byNorm.get(singular), ...byNorm.get(key)];
|
|
168
|
+
byNorm.set(singular, merged);
|
|
169
|
+
byNorm.delete(key);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
151
174
|
const conflicts = [];
|
|
152
175
|
for (const [norm, arr] of byNorm.entries()) {
|
|
153
176
|
if (allowSet.has(norm)) continue; // explicitly allowed
|