Skip to content

Commit 66d503a

Browse files
authored
chore: migrate spellchecking from github action to npm task (#2185)
Migrate from the cspell GitHub Action to the npm package. * Easier to run spellchecking locally. * More consistent setup between projects on GitHub or other forges. While I was doing this, I also amended the config to allow "compound words", then dropped any terms that were already in built-in dictionaries and that became redundant to add in our config after enabling compound words.
1 parent 27a0644 commit 66d503a

File tree

8 files changed

+924
-52
lines changed

8 files changed

+924
-52
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
cache: yarn
2626
- run: yarn install
2727
- run: yarn lint
28-
- run: yarn test:types
2928
types:
3029
name: Types
3130
runs-on: ubuntu-latest
@@ -38,6 +37,18 @@ jobs:
3837
cache: yarn
3938
- run: yarn install
4039
- run: yarn test:types
40+
spellcheck:
41+
name: Spell Check
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v5
45+
- run: corepack enable
46+
- uses: actions/setup-node@v5
47+
with:
48+
node-version: ${{ env.NODE }}
49+
cache: yarn
50+
- run: yarn install
51+
- run: yarn spellcheck
4152
test:
4253
name: ${{ matrix.os }} Node.js ${{ matrix.node-version }}
4354
strategy:

.github/workflows/spellcheck.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

cspell.jsonc

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
33
"version": "0.2",
4+
"allowCompoundWords": true,
45
"words": [
5-
"Bézier",
6-
"crosspoint",
76
"deoptimizations",
87
"deoptimize",
98
"deoptimized",
10-
"fontawesome",
119
"Fontello",
12-
"Fonticons",
13-
"frontends",
1410
"inlines",
15-
"opencollective",
16-
"subpoint",
17-
"subselector",
18-
"xast",
19-
"Xlink",
2011
// Abbreviations
2112
"elems", // elements
2213
"unenc", // unencoded
23-
// SVG Keywords
24-
"currentcolor",
2514
// SVG Nodes / Attributes and CSS Properties, including plurals
2615
"bbox",
2716
"hkern",
@@ -38,31 +27,23 @@
3827
// Storage
3928
"kibibytes",
4029
// Software
41-
"grunt-svgmin",
42-
"Inkscape",
4330
"SVGOMG",
44-
// NPM Packages
45-
"csstree",
46-
"csswhat",
4731
// Names
4832
"André",
4933
"Baranovskiy",
5034
"Dmitry",
5135
"Keerthi",
5236
],
5337
"ignorePaths": [
54-
".github/workflows/",
55-
".gitignore",
56-
".yarnrc.yml",
5738
"*.svg.txt",
5839
"*.svg",
40+
"coverage/",
5941
"cspell.jsonc",
42+
"dist/",
6043
"LICENSE",
6144
"test/regression/lists/",
6245
],
6346
"ignoreRegExpList": [
64-
"-moz", // Mozilla Firefox CSS prefix
65-
"'.+?.svg',", // path to file with .svg extension
6647
"(?:xlink|sodipodi)(?::[a-z]+)?", // Common SVG namespaces
6748
"[a-z]+: '#[a-f\\d]+',", // Color names in _collection.js
6849
"[a-z]+…", // Words that have been cut off by an ellipsis
@@ -71,21 +52,16 @@
7152
"\\*\\*SVG O\\*\\*ptimizer", // README
7253
"\\b[aprs]data\\b",
7354
"&.+?;", // HTML entity
74-
"^svgo .+", // Command-line example of SVGO
7555
"<svg.+>", // Inline SVG in code
7656
"Atrule", // At-rule
7757
"data:image/.+", // Data URI
7858
"datauri", // Data URI
7959
"descs", // Abbreviation of "descriptions"
8060
"ENOCLS|ENOATTRS",
81-
"id=([\"']).+?\\1", // ID attribute of inline SVG
8261
"import .+", // Import statements in Javascript
83-
"newres",
84-
"nums", // Abbreviation of "numbers"
8562
"onwarn", // Rollup API,
8663
"QRAB|QRCD",
8764
"rrggbb",
8865
"sax\\..+", // Any properties of the sax API
89-
"shorthex", // Parameter of convertColors plugin
9066
],
9167
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"clean": "yarn clean:build && yarn clean:types",
8989
"clean:build": "rimraf dist",
9090
"clean:types": "rimraf types",
91+
"spellcheck": "cspell -u .",
9192
"prepublishOnly": "yarn clean && yarn build"
9293
},
9394
"jest": {
@@ -123,6 +124,7 @@
123124
"@types/sax": "^1.2.7",
124125
"@types/tar-stream": "^3.1.3",
125126
"cross-env": "^7.0.3",
127+
"cspell": "^9.2.2",
126128
"eslint": "^9.25.1",
127129
"globals": "^14.0.0",
128130
"jest": "^29.7.0",

plugins/cleanupNumericValues.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ export const fn = (_root, params) => {
4444
element: {
4545
enter: (node) => {
4646
if (node.attributes.viewBox != null) {
47-
const nums = node.attributes.viewBox.trim().split(/(?:\s,?|,)\s*/g);
48-
node.attributes.viewBox = nums
47+
const numbers = node.attributes.viewBox
48+
.trim()
49+
.split(/(?:\s,?|,)\s*/g);
50+
node.attributes.viewBox = numbers
4951
.map((value) => {
5052
const num = Number(value);
5153
return Number.isNaN(num)

plugins/convertColors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const fn = (_root, params) => {
123123
if (rgb2hex) {
124124
const match = val.match(regRGB);
125125
if (match != null) {
126-
const nums = match.slice(1, 4).map((m) => {
126+
const numbers = match.slice(1, 4).map((m) => {
127127
let n;
128128
if (m.indexOf('%') > -1) {
129129
n = Math.round(parseFloat(m) * 2.55);
@@ -132,7 +132,7 @@ export const fn = (_root, params) => {
132132
}
133133
return Math.max(0, Math.min(n, 255));
134134
});
135-
val = convertRgbToHex(nums);
135+
val = convertRgbToHex(numbers);
136136
}
137137
}
138138

plugins/removeViewBox.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ export const fn = () => {
3131
if (node.name === 'svg' && parentNode.type !== 'root') {
3232
return;
3333
}
34-
const nums = node.attributes.viewBox.split(/[ ,]+/g);
34+
const numbers = node.attributes.viewBox.split(/[ ,]+/g);
3535
if (
36-
nums[0] === '0' &&
37-
nums[1] === '0' &&
38-
node.attributes.width.replace(/px$/, '') === nums[2] && // could use parseFloat too
39-
node.attributes.height.replace(/px$/, '') === nums[3]
36+
numbers[0] === '0' &&
37+
numbers[1] === '0' &&
38+
node.attributes.width.replace(/px$/, '') === numbers[2] && // could use parseFloat too
39+
node.attributes.height.replace(/px$/, '') === numbers[3]
4040
) {
4141
delete node.attributes.viewBox;
4242
}

0 commit comments

Comments
 (0)