color-name-list 11.25.0 → 12.0.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.
Files changed (40) hide show
  1. package/.vscode/tasks.json +48 -0
  2. package/README.md +5 -3
  3. package/changes.svg +3 -3
  4. package/dist/colornames.bestof.csv +24 -21
  5. package/dist/colornames.bestof.esm.js +1 -1
  6. package/dist/colornames.bestof.esm.mjs +1 -1
  7. package/dist/colornames.bestof.html +1 -1
  8. package/dist/colornames.bestof.json +1 -1
  9. package/dist/colornames.bestof.min.json +1 -1
  10. package/dist/colornames.bestof.scss +1 -1
  11. package/dist/colornames.bestof.umd.js +1 -1
  12. package/dist/colornames.bestof.xml +73 -61
  13. package/dist/colornames.bestof.yaml +57 -48
  14. package/dist/colornames.csv +49 -212
  15. package/dist/colornames.esm.js +1 -1
  16. package/dist/colornames.esm.mjs +1 -1
  17. package/dist/colornames.html +1 -1
  18. package/dist/colornames.json +1 -1
  19. package/dist/colornames.min.json +1 -1
  20. package/dist/colornames.scss +1 -1
  21. package/dist/colornames.short.csv +17 -17
  22. package/dist/colornames.short.esm.js +1 -1
  23. package/dist/colornames.short.esm.mjs +1 -1
  24. package/dist/colornames.short.html +1 -1
  25. package/dist/colornames.short.json +1 -1
  26. package/dist/colornames.short.min.json +1 -1
  27. package/dist/colornames.short.scss +1 -1
  28. package/dist/colornames.short.umd.js +1 -1
  29. package/dist/colornames.short.xml +54 -54
  30. package/dist/colornames.short.yaml +42 -42
  31. package/dist/colornames.umd.js +1 -1
  32. package/dist/colornames.xml +119 -771
  33. package/dist/colornames.yaml +96 -585
  34. package/dist/history.json +1 -1
  35. package/package.json +1 -1
  36. package/scripts/build.js +15 -2
  37. package/scripts/lib.js +55 -0
  38. package/src/colornames.csv +57 -220
  39. package/tests/duplicate-allowlist.json +12 -0
  40. package/tests/duplicates.test.js +70 -0
@@ -0,0 +1,12 @@
1
+ [
2
+ "Bird's Eye",
3
+ "Winter Green",
4
+ "Star Dust",
5
+ "Star Bright",
6
+ "Pi²",
7
+ "Pepper & Spice",
8
+ "Sable",
9
+ "Sablé",
10
+ "Rosé",
11
+ "Fresh Water"
12
+ ]
@@ -0,0 +1,70 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { findNearDuplicateNameConflicts } from '../scripts/lib.js';
5
+ import allowlist from './duplicate-allowlist.json';
6
+
7
+ describe('Duplicate-like color names', () => {
8
+ it('should not contain names that only differ by spacing/punctuation/case/accents', () => {
9
+ const csvPath = path.resolve('./src/colornames.csv');
10
+ const raw = fs.readFileSync(csvPath, 'utf8').replace(/\r\n/g, '\n').trimEnd();
11
+ const lines = raw.split('\n');
12
+ expect(lines.length).toBeGreaterThan(1);
13
+
14
+ const header = lines.shift();
15
+ expect(header.startsWith('name,hex')).toBe(true);
16
+
17
+ const items = lines.map((l, idx) => {
18
+ const lineNumber = idx + 2; // +1 for header, +1 because idx is 0-based
19
+ if (!l.trim()) return null;
20
+ const firstComma = l.indexOf(',');
21
+ const name = firstComma === -1 ? l : l.slice(0, firstComma);
22
+ return { name, lineNumber };
23
+ }).filter(Boolean);
24
+
25
+ const conflicts = findNearDuplicateNameConflicts(items, { allowlist });
26
+
27
+ if (conflicts.length) {
28
+ // Create a helpful error message with examples and hints.
29
+ const groupCount = conflicts.length;
30
+ const msgLines = [
31
+ `Found ${groupCount} duplicate-like group${groupCount === 1 ? '' : 's'} (case/accents/punctuation-insensitive):`,
32
+ '',
33
+ ];
34
+ conflicts
35
+ // make message deterministic by sorting
36
+ .sort((a, b) => a.norm.localeCompare(b.norm))
37
+ .forEach(({ norm, entries }) => {
38
+ const unique = [];
39
+ const seen = new Set();
40
+ // De-duplicate exact same name+line pairs in output
41
+ for (const e of entries) {
42
+ const key = `${e.name}@${e.lineNumber}`;
43
+ if (!seen.has(key)) {
44
+ seen.add(key);
45
+ unique.push(e);
46
+ }
47
+ }
48
+ // sort entries by line number for readability
49
+ unique.sort((a, b) => a.lineNumber - b.lineNumber);
50
+ msgLines.push(` • ${norm}:`);
51
+ unique.forEach((e) => msgLines.push(` - line ${e.lineNumber}: "${e.name}"`));
52
+ });
53
+
54
+ msgLines.push(
55
+ '',
56
+ 'This typically indicates near-duplicates that only differ by spacing/punctuation, like "Snow Pink" vs "Snowpink".',
57
+ 'Please unify or remove duplicates to keep the dataset clean.',
58
+ '',
59
+ 'Tip:',
60
+ ' - Edit src/colornames.csv and keep a single preferred spelling. When in doubt, prefer the most common or simplest form or the British spelling.',
61
+ ' - After changes, run: npm run sort-colors',
62
+ );
63
+
64
+ throw new Error(msgLines.join('\n'));
65
+ }
66
+
67
+ // If we reach here, no conflicts were found.
68
+ expect(conflicts.length).toBe(0);
69
+ });
70
+ });