color-name-list 13.42.0 → 14.1.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/README.md +2 -2
- package/changes.svg +3 -3
- package/dist/colornames.bestof.csv +52 -51
- 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.toon +53 -52
- package/dist/colornames.bestof.umd.js +1 -1
- package/dist/colornames.bestof.xml +88 -84
- package/dist/colornames.bestof.yaml +77 -74
- package/dist/colornames.csv +209 -220
- 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 +21 -23
- 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.toon +22 -24
- package/dist/colornames.short.umd.js +1 -1
- package/dist/colornames.short.xml +45 -53
- package/dist/colornames.short.yaml +38 -44
- package/dist/colornames.toon +210 -221
- package/dist/colornames.umd.js +1 -1
- package/dist/colornames.xml +398 -442
- package/dist/colornames.yaml +341 -374
- package/dist/history.json +1 -1
- package/package.json +1 -1
- package/scripts/fix-british-spellings.cjs +86 -0
- package/src/colornames.csv +210 -221
- package/tests/british-spelling-allowlist.json +16 -0
- package/tests/british-spelling.test.js +141 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Grayve-Yard",
|
|
3
|
+
"Center Field",
|
|
4
|
+
"Center Stage",
|
|
5
|
+
"Copper Harbor",
|
|
6
|
+
"Greys Harbor",
|
|
7
|
+
"Howdy Neighbor",
|
|
8
|
+
"UFO Defense Green",
|
|
9
|
+
"Winter Harbor",
|
|
10
|
+
"Center Ridge",
|
|
11
|
+
"Floppy Disk",
|
|
12
|
+
"Arbor Vitae",
|
|
13
|
+
"Red Hot Chili Pepper",
|
|
14
|
+
"Less Traveled",
|
|
15
|
+
"Eon"
|
|
16
|
+
]
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
2
|
+
import { csvTestData } from './csv-test-data.js';
|
|
3
|
+
import britishSpellingAllowlist from './british-spelling-allowlist.json';
|
|
4
|
+
import { buildFailureMessage } from './_utils/report.js';
|
|
5
|
+
|
|
6
|
+
describe('British English Spelling', () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
csvTestData.load();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* American to British spelling patterns
|
|
13
|
+
* Each entry: [American pattern (regex), British replacement, description]
|
|
14
|
+
*/
|
|
15
|
+
const americanToBritishPatterns = [
|
|
16
|
+
// -or vs -our (color/colour, honor/honour, etc.)
|
|
17
|
+
// But NOT: glamor (acceptable), or words like "or", "for", "nor"
|
|
18
|
+
[/\b(\w*)(arb|arm|behavi|col|enam|endeav|fav|ferv|flav|glam|harb|hon|hum|lab|neighb|od|parl|rum|sav|splend|val|vap|vig)or(ed|ing|y|ful|less|able|er|ist|hood|ite|al|ly|s)?\b/gi, '$1$2our$3', '-or should be -our (e.g., colour, honour)'],
|
|
19
|
+
|
|
20
|
+
// -ize vs -ise (organize/organise, realize/realise, etc.)
|
|
21
|
+
// Note: Some -ize words are acceptable in British English, so we only flag common ones
|
|
22
|
+
[/\b(\w*)(agon|appet|apolog|author|capital|caramel|categor|character|colon|critic|crystall|emphas|energ|equal|fantas|fertil|final|fossil|legal|maxim|memor|mesmer|minim|mobil|modern|normal|optim|organ|paraly|popular|priorit|real|recogn|stabil|standard|summar|symbol|synchron|tantal|terror|util|vandal|vapor|visual|vulcan)iz(e|ed|es|ing|er|ation|able)\b/gi, '$1$2is$3', '-ize should be -ise (e.g., organise, realise)'],
|
|
23
|
+
|
|
24
|
+
// -er vs -re (center/centre, theater/theatre, etc.)
|
|
25
|
+
[/\b(calib|cent|epicent|fib|goit|lit|lust|meag|met|nit|och|reconnoit|sab|scept|sepulch|somb|spect|theat|tit)er\b/gi, '$1re', '-er should be -re (e.g., centre, theatre)'],
|
|
26
|
+
// Special case: maneuver -> manoeuvre
|
|
27
|
+
[/\b(maneuver)\b/gi, 'manoeuvre', '-er should be -re (e.g., centre, theatre)'],
|
|
28
|
+
// Special case: miter -> mitre
|
|
29
|
+
[/\b(mit)er\b/gi, '$1re', '-er should be -re (e.g., centre, theatre)'],
|
|
30
|
+
|
|
31
|
+
// -ense vs -ence (defense/defence, offense/offence, etc.)
|
|
32
|
+
[/\b(def|off|pret|lic)ense\b/gi, '$1ence', '-ense should be -ence (e.g., defence, offence)'],
|
|
33
|
+
|
|
34
|
+
// -og vs -ogue (catalog/catalogue, dialog/dialogue, etc.)
|
|
35
|
+
[/\b(anal|catal|dial|monol|prol)og\b/gi, '$1ogue', '-og should be -ogue (e.g., catalogue, dialogue)'],
|
|
36
|
+
|
|
37
|
+
// -eled/-eling vs -elled/-elling (traveled/travelled, etc.)
|
|
38
|
+
[/\b(\w*)(bevel|cancel|carol|channel|fuel|label|level|model|panel|signal|travel)(ed|ing)\b/gi, '$1$2l$3', 'should use double l (e.g., travelled, cancelled)'],
|
|
39
|
+
|
|
40
|
+
// gray vs grey
|
|
41
|
+
[/\bgray(\w*)\b/gi, 'grey$1', 'should be "grey" (British spelling)'],
|
|
42
|
+
|
|
43
|
+
// Specific common words
|
|
44
|
+
[/\b(A|a)irplane(\w*)\b/g, '$1eroplane$2', 'should be "aeroplane" (British spelling)'],
|
|
45
|
+
[/\b(A|a)rcheolog(\w*)\b/g, '$1rchaeolog$2', 'should be "archaeology" (British spelling)'],
|
|
46
|
+
[/\b(A|a)rtifact(\w*)\b/g, '$1rtefact$2', 'should be "artefact" (British spelling)'],
|
|
47
|
+
[/\b(C|c)heckered\b/g, '$1hequered', 'should be "chequered" (British spelling)'],
|
|
48
|
+
[/\b(C|c)hili\b/g, '$1hilli', 'should be "chilli" (British spelling)'],
|
|
49
|
+
[/\b(C|c)himera\b/g, '$1himaera', 'should be "chimaera" (British spelling)'],
|
|
50
|
+
[/\b(C|c)ozy\b/g, '$1osy', 'should be "cosy" (British spelling)'],
|
|
51
|
+
[/\b(D|d)isk\b/g, '$1isc', 'should be "disc" (British spelling)'],
|
|
52
|
+
[/\b(D|d)onut(\w*)\b/g, '$1oughnut$2', 'should be "doughnut" (British spelling)'],
|
|
53
|
+
[/\b(D|d)raft(\w*)\b/g, '$1raught$2', 'should be "draught" (British spelling)'],
|
|
54
|
+
[/\b(E|e)on\b/g, '$1eon', 'should be "aeon" (British spelling)'],
|
|
55
|
+
[/\b(G|g)riffin\b/g, '$1ryphon', 'should be "gryphon" (British spelling)'],
|
|
56
|
+
[/\b(H|h)emoglobin\b/g, '$1aemoglobin', 'should be "haemoglobin" (British spelling)'],
|
|
57
|
+
[/\b(H|h)omeopath(\w*)\b/g, '$1omoeopath$2', 'should be "homoeopathy" (British spelling)'],
|
|
58
|
+
[/\b(J|j)ewelry\b/g, '$1ewellery', 'should be "jewellery" (British spelling)'],
|
|
59
|
+
[/\b(M|m)arvelous\b/g, '$1arvellous', 'should be "marvellous" (British spelling)'],
|
|
60
|
+
[/\b(M|m)old(y|er)?\b/g, '$1ould$2', 'should be "mould/mouldy/moulder" (British spelling)'],
|
|
61
|
+
[/\b(M|m)ustache\b/g, '$1oustache', 'should be "moustache" (British spelling)'],
|
|
62
|
+
[/\b(P|p)ajamas\b/g, '$1yjamas', 'should be "pyjamas" (British spelling)'],
|
|
63
|
+
[/\b(P|p)low(\w*)\b/g, '$1lough$2', 'should be "plough" (British spelling)'],
|
|
64
|
+
[/\b(M|m)olt(?!en)(\w*)\b/g, '$1oult$2', 'should be "moult" (British spelling)'],
|
|
65
|
+
[/\b(S|s)keptic(\w*)\b/g, '$1ceptic$2', 'should be "sceptic" (British spelling)'],
|
|
66
|
+
[/\b(S|s)molder(\w*)\b/g, '$1moulder$2', 'should be "smoulder" (British spelling)'],
|
|
67
|
+
[/\b(S|s)ulfur(\w*)\b/g, '$1ulphur$2', 'should be "sulphur" (British spelling)'],
|
|
68
|
+
[/\b(T|t)ranquility\b/g, '$1ranquillity', 'should be "tranquillity" (British spelling)'],
|
|
69
|
+
[/\b(W|w)ool(en|y)\b/g, '$1ooll$2', 'should be "woollen/woolly" (British spelling)'],
|
|
70
|
+
[/\b(Y|y)ogurt\b/g, '$1oghurt', 'should be "yoghurt" (British spelling)'],
|
|
71
|
+
[/\b(A|a)luminum\b/g, '$1luminium', 'should be "aluminium" (British spelling)'],
|
|
72
|
+
[/\b(A|a)ging\b/g, '$1geing', 'should be "ageing" (British spelling)'],
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
it('should use British English spelling (unless in allowlist)', () => {
|
|
76
|
+
const allowlistSet = new Set(
|
|
77
|
+
britishSpellingAllowlist.map((name) => name.toLowerCase())
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const americanSpellings = [];
|
|
81
|
+
|
|
82
|
+
csvTestData.data.entries.forEach((entry, index) => {
|
|
83
|
+
const name = entry.name;
|
|
84
|
+
|
|
85
|
+
// Skip if in allowlist
|
|
86
|
+
if (allowlistSet.has(name.toLowerCase())) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Check each pattern
|
|
91
|
+
for (const [pattern, replacement, description] of americanToBritishPatterns) {
|
|
92
|
+
const match = name.match(pattern);
|
|
93
|
+
if (match) {
|
|
94
|
+
americanSpellings.push({
|
|
95
|
+
name,
|
|
96
|
+
match: match[0],
|
|
97
|
+
issue: description,
|
|
98
|
+
lineNumber: index + 2,
|
|
99
|
+
suggestion: name.replace(pattern, replacement),
|
|
100
|
+
});
|
|
101
|
+
break; // Only report first issue per name
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (americanSpellings.length > 0) {
|
|
107
|
+
const details = americanSpellings.map(
|
|
108
|
+
({ name, match, issue, lineNumber, suggestion }) =>
|
|
109
|
+
` * line ${lineNumber}: "${name}" contains "${match}" - ${issue} (Suggested: "${suggestion}")`
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
throw new Error(
|
|
113
|
+
buildFailureMessage({
|
|
114
|
+
title: 'Found {n} color {items} with American English spelling:',
|
|
115
|
+
offenders: americanSpellings.map((item) => item.name),
|
|
116
|
+
offenderLabel: 'name',
|
|
117
|
+
details: [
|
|
118
|
+
...details,
|
|
119
|
+
'',
|
|
120
|
+
'As per CONTRIBUTING.md, use British English spelling unless the name',
|
|
121
|
+
'refers to something typically American (place names, proper nouns, etc.)',
|
|
122
|
+
'',
|
|
123
|
+
'Common differences:',
|
|
124
|
+
' • color → colour',
|
|
125
|
+
' • gray → grey',
|
|
126
|
+
' • center → centre',
|
|
127
|
+
' • honor → honour',
|
|
128
|
+
' • organize → organise',
|
|
129
|
+
],
|
|
130
|
+
tips: [
|
|
131
|
+
'Fix the spelling in src/colornames.csv',
|
|
132
|
+
'Or add the name to tests/british-spelling-allowlist.json if the American spelling is intentional',
|
|
133
|
+
'After changes, run: npm run sort-colors',
|
|
134
|
+
],
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
expect(americanSpellings.length).toBe(0);
|
|
140
|
+
});
|
|
141
|
+
});
|