Skip to content

Commit bf7f9dd

Browse files
committed
Refactor token-utils loops; mark TODO items done
Replace forEach callbacks with for..of loops in scripts/token-utils.ts to make control flow explicit (use continue instead of callback return) and simplify deepMerge by iterating Object.entries and avoiding redundant lookups. Update TODO.md to mark Tailwind preset composition and CSS variable integration checks as completed and add notes pointing to the example/integration-fixture and check:integration validation.
1 parent 2df6c14 commit bf7f9dd

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

TODO.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ design synchronization, and safe retirement paths.
8686
- Validate that the package works the way downstream packages actually
8787
consume it, not just that the token shape is correct in isolation.
8888

89-
- [ ] Validate Tailwind preset composition against a downstream config
89+
- [x] Validate Tailwind preset composition against a downstream config
9090
- Confirm the preset composes correctly with a consumer Tailwind config that
9191
has its own theme extensions. Catch namespace collisions and merge conflicts.
92+
- Delivered via `example/integration-fixture/` validated by `check:integration`.
9293

93-
- [ ] Validate CSS variable output in a real integration context
94+
- [x] Validate CSS variable output in a real integration context
9495
- Confirm variables do not collide with or shadow downstream CSS when the
9596
package is used alongside `spectre-ui`.
97+
- Delivered via `example/integration-fixture/layer.css` and `check:integration`
98+
namespace-collision checks.
9699

97100
- [x] Document any integration constraints as explicit contract rules
98101
- Add integration-level requirements to `TOKEN_CONTRACT.md` so they are part

scripts/token-utils.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,19 @@ function assertNoDuplicateTokenPaths(files: string[]): void {
3030
const owners = new Map<string, string>();
3131
const duplicates: string[] = [];
3232

33-
files.forEach((file) => {
33+
for (const file of files) {
3434
const fullPath = join(TOKENS_DIR, file);
3535
const content = JSON.parse(readFileSync(fullPath, 'utf8')) as Record<string, unknown>;
3636

37-
collectLeafPaths(content).forEach((tokenPath) => {
37+
for (const tokenPath of collectLeafPaths(content)) {
3838
const existingOwner = owners.get(tokenPath);
3939
if (existingOwner && existingOwner !== file) {
4040
duplicates.push(`${tokenPath} (${existingOwner}, ${file})`);
41-
return;
41+
continue;
4242
}
43-
4443
owners.set(tokenPath, file);
45-
});
46-
});
44+
}
45+
}
4746

4847
if (duplicates.length > 0) {
4948
throw new Error(
@@ -57,19 +56,16 @@ function assertNoDuplicateTokenPaths(files: string[]): void {
5756
}
5857

5958
function deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown> {
60-
Object.keys(source).forEach(key => {
59+
for (const [key, sourceValue] of Object.entries(source)) {
6160
const targetValue = target[key];
62-
const sourceValue = source[key];
63-
6461
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
6562
target[key] = sourceValue;
6663
} else if (isObject(targetValue) && isObject(sourceValue)) {
6764
target[key] = deepMerge({ ...targetValue }, sourceValue);
6865
} else {
6966
target[key] = sourceValue;
7067
}
71-
});
72-
68+
}
7369
return target;
7470
}
7571

0 commit comments

Comments
 (0)