color-name-list 13.19.2 → 13.20.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 (46) hide show
  1. package/.github/workflows/build-and-release.yml +1 -0
  2. package/.github/workflows/build.yml +5 -3
  3. package/CONTRIBUTING.md +1 -0
  4. package/changes.svg +3 -3
  5. package/dist/colornames.bestof.csv +4711 -4710
  6. package/dist/colornames.bestof.esm.js +1 -1
  7. package/dist/colornames.bestof.esm.mjs +1 -1
  8. package/dist/colornames.bestof.html +1 -1
  9. package/dist/colornames.bestof.json +1 -1
  10. package/dist/colornames.bestof.min.json +1 -1
  11. package/dist/colornames.bestof.scss +1 -1
  12. package/dist/colornames.bestof.toon +2 -1
  13. package/dist/colornames.bestof.umd.js +1 -1
  14. package/dist/colornames.bestof.xml +5 -1
  15. package/dist/colornames.bestof.yaml +4 -1
  16. package/dist/colornames.csv +29991 -29991
  17. package/dist/colornames.esm.js +1 -1
  18. package/dist/colornames.esm.mjs +1 -1
  19. package/dist/colornames.html +1 -1
  20. package/dist/colornames.json +1 -1
  21. package/dist/colornames.min.json +1 -1
  22. package/dist/colornames.scss +1 -1
  23. package/dist/colornames.short.csv +2966 -2965
  24. package/dist/colornames.short.esm.js +1 -1
  25. package/dist/colornames.short.esm.mjs +1 -1
  26. package/dist/colornames.short.html +1 -1
  27. package/dist/colornames.short.json +1 -1
  28. package/dist/colornames.short.min.json +1 -1
  29. package/dist/colornames.short.scss +1 -1
  30. package/dist/colornames.short.toon +2 -1
  31. package/dist/colornames.short.umd.js +1 -1
  32. package/dist/colornames.short.xml +5 -1
  33. package/dist/colornames.short.yaml +4 -1
  34. package/dist/colornames.toon +4 -4
  35. package/dist/colornames.umd.js +1 -1
  36. package/dist/colornames.xml +13 -13
  37. package/dist/colornames.yaml +10 -10
  38. package/dist/history.json +1 -1
  39. package/package.json +1 -1
  40. package/scripts/build.js +7 -3
  41. package/scripts/sortSrc.js +2 -2
  42. package/src/colornames.csv +4 -4
  43. package/tests/allowlists.test.js +76 -0
  44. package/tests/duplicate-allowlist.json +1 -2
  45. package/tests/title-case-allowlist.json +0 -1
  46. package/tests/validations.test.js +22 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "color-name-list",
3
- "version": "13.19.2",
3
+ "version": "13.20.0",
4
4
  "description": "long list of color names",
5
5
  "main": "dist/colornames.json",
6
6
  "browser": "dist/colornames.umd.js",
package/scripts/build.js CHANGED
@@ -178,12 +178,15 @@ fs.writeFileSync(
178
178
  const outputFormats = {
179
179
  csv: {
180
180
  insertBefore: csvKeys.join(',') + '\n',
181
+ rowDelimitor: '\n',
182
+ insertAfter: '\n',
181
183
  },
182
184
  toon: {
183
185
  // TOON tabular array header for flat objects: [N]{name,hex}:
184
186
  insertBefore: `[${colorsSrc.entries.length}]{${csvKeys.join(',')}}:\n `,
185
187
  itemDelimitor: ',',
186
188
  rowDelimitor: '\n ',
189
+ insertAfter: '\n',
187
190
  },
188
191
  yaml: {
189
192
  insertBefore: '-\n ',
@@ -192,12 +195,13 @@ const outputFormats = {
192
195
  includeKeyPerItem: true,
193
196
  rowDelimitor: '\n-\n ',
194
197
  itemDelimitor: '\n ',
198
+ insertAfter: '\n',
195
199
  },
196
200
  scss: {
197
201
  insertBefore: '$color-name-list: (',
198
202
  beforeValue: '"',
199
203
  afterValue: '"',
200
- insertAfter: ');',
204
+ insertAfter: ');\n',
201
205
  itemDelimitor: ':',
202
206
  rowDelimitor: ',',
203
207
  },
@@ -205,13 +209,13 @@ const outputFormats = {
205
209
  insertBefore: `<table><thead><tr><th>${csvKeys.join('</th><th>')}</th></tr><thead><tbody><tr><td>`,
206
210
  itemDelimitor: '</td><td>',
207
211
  rowDelimitor: '</td></tr><tr><td>',
208
- insertAfter: `</td></tr></tbody></table>`,
212
+ insertAfter: `</td></tr></tbody></table>\n`,
209
213
  },
210
214
  xml: {
211
215
  insertBefore: `<?xml version='1.0'?>\n<colors>\n<color>\n<${csvKeys[0]}>`,
212
216
  itemDelimitor: `</${csvKeys[0]}>\n<${csvKeys[1]}>`,
213
217
  rowDelimitor: `</${csvKeys[1]}>\n</color>\n<color>\n<${csvKeys[0]}>`,
214
- insertAfter: `</${csvKeys[1]}>\n</color>\n</colors>`,
218
+ insertAfter: `</${csvKeys[1]}>\n</color>\n</colors>\n`,
215
219
  },
216
220
  };
217
221
 
@@ -41,11 +41,11 @@ const readAndSortCSV = () => {
41
41
  // Extract the name from each line (first column before the comma)
42
42
  const nameA = a.split(',')[0].toLowerCase();
43
43
  const nameB = b.split(',')[0].toLowerCase();
44
- return nameA.localeCompare(nameB);
44
+ return nameA.localeCompare(nameB, 'en');
45
45
  });
46
46
 
47
47
  // Combine header & sorted lines (no blank line). Ensure exactly one final newline.
48
- const sortedData = [header, ...sortedColorLines].join('\n');
48
+ const sortedData = [header, ...sortedColorLines].join('\n') + '\n';
49
49
 
50
50
  // Write back
51
51
  fs.writeFileSync(csvPath, sortedData, 'utf8');
@@ -2495,14 +2495,13 @@ Bird Blue Grey,#7f92a0,
2495
2495
  Bird Flower,#d0c117,
2496
2496
  Bird’s Child,#fff1cf,
2497
2497
  Bird’s Egg Green,#aaccb9,
2498
- Bird’s Eye,#b9030a,
2499
2498
  Bird’s Nest,#cfbb9b,
2499
+ Bird’s-Eye,#ab823d,
2500
+ Bird’s-Eye Maple,#e4c495,
2500
2501
  Birdhouse Brown,#6c483a,
2501
2502
  Birdie,#e9e424,
2502
2503
  Birdie Num Num,#89acda,x
2503
2504
  Birdseed,#e2c28e,
2504
- Birdseye,#ab823d,
2505
- Birdseye Maple,#e4c495,
2506
2505
  Biro Blue,#2f3946,
2507
2506
  Birōdo Green,#224634,
2508
2507
  Birth of a Star,#fce9df,
@@ -3975,6 +3974,7 @@ Bull Shot,#75442b,
3975
3974
  Bullet Hell,#faf1c8,x
3976
3975
  Bullfighters Red,#cd4646,
3977
3976
  Bullfrog,#8a966a,x
3977
+ Bullseye,#b9030a,x
3978
3978
  Bulma Hair,#359e6b,x
3979
3979
  Bulrush,#6d5837,
3980
3980
  Bumangués Blue,#0777bc,
@@ -29989,4 +29989,4 @@ Zumthor,#cdd5d5,
29989
29989
  Zunda Green,#6bc026,x
29990
29990
  Zuni,#008996,
29991
29991
  Zürich Blue,#248bcc,
29992
- Zürich White,#e6e1d9,
29992
+ Zürich White,#e6e1d9,
@@ -0,0 +1,76 @@
1
+ import { describe, it, expect, beforeAll } from 'vitest';
2
+ import { csvTestData } from './csv-test-data.js';
3
+ import duplicateAllowlist from './duplicate-allowlist.json';
4
+ import duplicatePluralsAllowlist from './duplicate-plurals-allowlist.json';
5
+ import titleCaseAllowlist from './title-case-allowlist.json';
6
+ import { buildFailureMessage } from './_utils/report.js';
7
+
8
+ describe('Allowlists Validation', () => {
9
+ beforeAll(() => {
10
+ // Load CSV data once for all tests
11
+ csvTestData.load();
12
+ });
13
+
14
+ const allColorNames = new Set();
15
+
16
+ beforeAll(() => {
17
+ csvTestData.data.values['name'].forEach(name => allColorNames.add(name));
18
+ });
19
+
20
+ it('should ensure all entries in duplicate-allowlist.json exist in colornames.csv', () => {
21
+ const missingEntries = duplicateAllowlist.filter(name => !allColorNames.has(name));
22
+
23
+ if (missingEntries.length) {
24
+ throw new Error(
25
+ buildFailureMessage({
26
+ title: 'Found {n} unused {items} in duplicate-allowlist.json:',
27
+ offenders: missingEntries,
28
+ offenderLabel: 'entry',
29
+ details: [
30
+ 'These names are listed in the allowlist but do not exist in src/colornames.csv.',
31
+ 'Please remove them from tests/duplicate-allowlist.json to keep the list clean.',
32
+ ],
33
+ })
34
+ );
35
+ }
36
+ expect(missingEntries.length).toBe(0);
37
+ });
38
+
39
+ it('should ensure all entries in duplicate-plurals-allowlist.json exist in colornames.csv', () => {
40
+ const missingEntries = duplicatePluralsAllowlist.filter(name => !allColorNames.has(name));
41
+
42
+ if (missingEntries.length) {
43
+ throw new Error(
44
+ buildFailureMessage({
45
+ title: 'Found {n} unused {items} in duplicate-plurals-allowlist.json:',
46
+ offenders: missingEntries,
47
+ offenderLabel: 'entry',
48
+ details: [
49
+ 'These names are listed in the allowlist but do not exist in src/colornames.csv.',
50
+ 'Please remove them from tests/duplicate-plurals-allowlist.json to keep the list clean.',
51
+ ],
52
+ })
53
+ );
54
+ }
55
+ expect(missingEntries.length).toBe(0);
56
+ });
57
+
58
+ it('should ensure all entries in title-case-allowlist.json exist in colornames.csv', () => {
59
+ const missingEntries = titleCaseAllowlist.filter(name => !allColorNames.has(name));
60
+
61
+ if (missingEntries.length) {
62
+ throw new Error(
63
+ buildFailureMessage({
64
+ title: 'Found {n} unused {items} in title-case-allowlist.json:',
65
+ offenders: missingEntries,
66
+ offenderLabel: 'entry',
67
+ details: [
68
+ 'These names are listed in the allowlist but do not exist in src/colornames.csv.',
69
+ 'Please remove them from tests/title-case-allowlist.json to keep the list clean.',
70
+ ],
71
+ })
72
+ );
73
+ }
74
+ expect(missingEntries.length).toBe(0);
75
+ });
76
+ });
@@ -1,5 +1,4 @@
1
1
  [
2
- "Bird's Eye",
3
2
  "Winter Green",
4
3
  "Star Dust",
5
4
  "Star Bright",
@@ -19,7 +18,7 @@
19
18
  "Sail On",
20
19
  "In the Red",
21
20
  "In the Pink",
22
- "In A Pickle",
21
+ "In a Pickle",
23
22
  "In for a Penny",
24
23
  "On the Nile",
25
24
  "In the Navy",
@@ -9,7 +9,6 @@
9
9
  "Mauve-a-Lish",
10
10
  "Peek-a-Blue",
11
11
  "Apple-a-Day",
12
- "Banan-appeal",
13
12
  "Fly-by-Night",
14
13
  "Down-to-Earth",
15
14
  "Iron-ic",
@@ -30,9 +30,27 @@ describe('CSV Data Validations', () => {
30
30
  });
31
31
 
32
32
  if (invalidHexCodes.length) {
33
- const details = invalidHexCodes.map(
34
- ({ hex, name, lineNumber }) => ` * line ${lineNumber}: "${name}" -> ${hex}`
35
- );
33
+ const details = invalidHexCodes.map(({ hex, name, lineNumber }) => {
34
+ let msg = ` * line ${lineNumber}: "${name}" -> "${hex}"`;
35
+ if (hex.trim() !== hex) {
36
+ msg += ' (contains surrounding whitespace)';
37
+ }
38
+ return msg;
39
+ });
40
+
41
+ const hasWhitespaceIssues = invalidHexCodes.some((i) => i.hex.trim() !== i.hex);
42
+ const tips = [
43
+ 'Edit src/colornames.csv and fix the hex values',
44
+ 'Use lowercase letters only: a-f',
45
+ 'Always use 6 characters: #rrggbb format',
46
+ ];
47
+
48
+ if (hasWhitespaceIssues) {
49
+ tips.push('Remove any leading or trailing spaces around the hex code');
50
+ }
51
+
52
+ tips.push('After changes, run: npm run sort-colors');
53
+
36
54
  throw new Error(
37
55
  buildFailureMessage({
38
56
  title: 'Found {n} invalid hex color {items}:',
@@ -45,12 +63,7 @@ describe('CSV Data Validations', () => {
45
63
  'Examples of valid hex codes: #ff0000, #a1b2c3, #000000',
46
64
  'Examples of invalid hex codes: #f00 (too short), #FF0000 (uppercase), #gghhii (invalid characters)',
47
65
  ],
48
- tips: [
49
- 'Edit src/colornames.csv and fix the hex values',
50
- 'Use lowercase letters only: a-f',
51
- 'Always use 6 characters: #rrggbb format',
52
- 'After changes, run: npm run sort-colors',
53
- ],
66
+ tips,
54
67
  })
55
68
  );
56
69
  }