From d59c83cf23d40ee3373a14c6537f1e780246189a Mon Sep 17 00:00:00 2001
From: destrox
Date: Tue, 27 Oct 2026 21:56:00 +0100
Subject: [PATCH 1/4] chore: Create scripts for checking cspell alphabetical
order
---
.github/workflows/validate.yml | 3 +++
package.json | 2 ++
scripts/check-cspell-order.ts | 46 ++++++++++++++++++++++++++++++++++
scripts/format-cspell-order.ts | 43 +++++++++++++++++++++++++++++++
4 files changed, 94 insertions(+)
create mode 100644 scripts/check-cspell-order.ts
create mode 100644 scripts/format-cspell-order.ts
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index d673f789a..1055fc6a7 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -23,6 +23,9 @@ jobs:
- name: Build All Packages
run: bun run buildc all
+ - name: Check cspell word order
+ run: bun run cspell-order:check
+
- name: Basic Checks
run: bun run check
diff --git a/package.json b/package.json
index e4485d289..902e3d81a 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,8 @@
],
"scripts": {
"check": "check && bun run --sequential --workspaces check",
+ "cspell-order:check": "bun run scripts/check-cspell-order.ts",
+ "cspell-order:format": "bun run scripts/format-cspell-order.ts",
"test": "bun run --workspaces test run",
"test:coverage": "bun run --workspaces test:coverage",
"prepare": "simple-git-hooks",
diff --git a/scripts/check-cspell-order.ts b/scripts/check-cspell-order.ts
new file mode 100644
index 000000000..5b5cf7697
--- /dev/null
+++ b/scripts/check-cspell-order.ts
@@ -0,0 +1,46 @@
+const configPath = 'cspell.yml';
+const lines = (await Bun.file(configPath).text()).split('\n');
+const wordsSectionIndex = lines.findIndex((line) => /^words:\s*$/.test(line));
+
+if (wordsSectionIndex === -1) {
+ throw new Error(`Could not find the words section in ${configPath}`);
+}
+
+const words: { line: number; value: string }[] = [];
+
+for (let index = wordsSectionIndex + 1; index < lines.length; index++) {
+ const line = lines[index];
+ const wordMatch = line.match(/^ {2}- (.*)$/);
+
+ if (wordMatch) {
+ words.push({ line: index + 1, value: wordMatch[1] });
+ continue;
+ }
+
+ if (line.trim() && !line.startsWith(' ')) break;
+}
+
+const outOfOrder = words.flatMap((word, index) => {
+ if (index === 0) return [];
+
+ const previous = words[index - 1];
+ return previous.value.toLowerCase() > word.value.toLowerCase()
+ ? [{ previous, word }]
+ : [];
+});
+
+if (outOfOrder.length > 0) {
+ console.error(
+ `${configPath}: words must be sorted alphabetically (case-insensitive):`,
+ );
+ for (const { previous, word } of outOfOrder) {
+ console.error(
+ ` line ${word.line} "${word.value.slice(0, 40)}" is before line ${previous.line} "${previous.value.slice(0, 40)}"`,
+ );
+ }
+ process.exitCode = 1;
+} else {
+ console.log(`${configPath}: words are sorted alphabetically.`);
+}
+
+export default {};
diff --git a/scripts/format-cspell-order.ts b/scripts/format-cspell-order.ts
new file mode 100644
index 000000000..c60775507
--- /dev/null
+++ b/scripts/format-cspell-order.ts
@@ -0,0 +1,43 @@
+const configPath = 'cspell.yml';
+const originalConfig = await Bun.file(configPath).text();
+const lines = originalConfig.split('\n');
+const wordsSectionIndex = lines.findIndex((line) => /^words:\s*$/.test(line));
+
+if (wordsSectionIndex === -1) {
+ throw new Error(`Could not find the words section in ${configPath}`);
+}
+
+const wordLines: { index: number; line: string; value: string }[] = [];
+
+for (let index = wordsSectionIndex + 1; index < lines.length; index++) {
+ const line = lines[index];
+ const wordMatch = line.match(/^ {2}- (.*)$/);
+
+ if (wordMatch) {
+ wordLines.push({ index, line, value: wordMatch[1] });
+ continue;
+ }
+
+ if (line.trim() && !line.startsWith(' ')) break;
+}
+
+const sortedWordLines = [...wordLines].sort((a, b) => {
+ const first = a.value.toLowerCase();
+ const second = b.value.toLowerCase();
+ return first < second ? -1 : first > second ? 1 : 0;
+});
+
+for (const [index, wordLine] of wordLines.entries()) {
+ lines[wordLine.index] = sortedWordLines[index].line;
+}
+
+const sortedConfig = lines.join('\n');
+
+if (sortedConfig !== originalConfig) {
+ await Bun.write(configPath, sortedConfig);
+ console.log(`${configPath}: sorted words alphabetically.`);
+} else {
+ console.log(`${configPath}: words are already sorted alphabetically.`);
+}
+
+export default {};
From a708c6a98ff1689ec4d1d550f1cd144bf7b7083f Mon Sep 17 00:00:00 2001
From: Patryk Kuniczak
Date: Sun, 1 Nov 2026 10:28:50 +0100
Subject: [PATCH 2/4] Update package.json
Co-authored-by: Suvesh Moza
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 902e3d81a..f41ef93b9 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"packages/*"
],
"scripts": {
- "check": "check && bun run --sequential --workspaces check",
+ "check": "cspell-order:check && check && bun run --sequential --workspaces check",
"cspell-order:check": "bun run scripts/check-cspell-order.ts",
"cspell-order:format": "bun run scripts/format-cspell-order.ts",
"test": "bun run --workspaces test run",
From 5b99f30ef947f7a9b5a57c99645c1bf2e7acb1c6 Mon Sep 17 00:00:00 2001
From: destrox
Date: Sun, 1 Nov 2026 10:32:10 +0100
Subject: [PATCH 3/4] add `bun run` before new script for `check`
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index f41ef93b9..8ce293233 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"packages/*"
],
"scripts": {
- "check": "cspell-order:check && check && bun run --sequential --workspaces check",
+ "check": "bun run cspell-order:check && check && bun run --sequential --workspaces check",
"cspell-order:check": "bun run scripts/check-cspell-order.ts",
"cspell-order:format": "bun run scripts/format-cspell-order.ts",
"test": "bun run --workspaces test run",
From ed882d0bf0f209d94a467ccb21ce823824ac7871 Mon Sep 17 00:00:00 2001
From: destrox
Date: Sun, 1 Nov 2026 10:33:19 +0100
Subject: [PATCH 4/4] Remove `Check cspell word order` from validate.yml
---
.github/workflows/validate.yml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index 1055fc6a7..d673f789a 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -23,9 +23,6 @@ jobs:
- name: Build All Packages
run: bun run buildc all
- - name: Check cspell word order
- run: bun run cspell-order:check
-
- name: Basic Checks
run: bun run check