Skip to content

Commit c38d2a7

Browse files
bartvenemanBart Veneman
andauthored
BREAKING: Dedupe tokens: color, font-size, line-height, duration (#28)
* dedupe font-sizes * dedupe line heights * deduplicate colors, line-heights, font-sizes and durations * BREAKING: target node v22+, rewrite some stuff * rm more tsconfig * upgrade GH actions to v5 for Node 24 * fix CI node versions --------- Co-authored-by: Bart Veneman <[email protected]>
1 parent 6d5f2c3 commit c38d2a7

File tree

10 files changed

+367
-74
lines changed

10 files changed

+367
-74
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@ jobs:
1111
test:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
15-
- uses: actions/setup-node@v4
16-
- run: npm install --ignore-scripts --no-audit --no-fund
14+
- uses: actions/checkout@v5
15+
- uses: actions/setup-node@v5
16+
with:
17+
cache: "npm"
18+
node-version: 22
19+
- run: npm ci --ignore-scripts --no-audit --no-fund
1720
- run: npm test
1821

1922
publish-npm:
2023
needs: test
2124
runs-on: ubuntu-latest
2225
steps:
23-
- uses: actions/checkout@v4
24-
- uses: actions/setup-node@v4
26+
- uses: actions/checkout@v5
27+
- uses: actions/setup-node@v5
2528
with:
26-
cache: 'npm'
29+
node-version: 22
30+
cache: "npm"
2731
registry-url: https://registry.npmjs.org/
28-
- run: npm install --ignore-scripts --no-audit --no-fund
32+
- run: npm ci --ignore-scripts --no-audit --no-fund
2933
- run: npm run build
3034
- run: npm publish --public
3135
env:

.github/workflows/test.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@ jobs:
1414
name: Unit tests
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818
- name: Use Node.js
19-
uses: actions/setup-node@v4
19+
uses: actions/setup-node@v5
2020
with:
2121
cache: "npm"
22+
node-version: 22
2223
- run: npm install --ignore-scripts --no-audit --no-fund
2324
- run: npm test
2425

2526
check:
2627
name: Check types
2728
runs-on: ubuntu-latest
2829
steps:
29-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@v5
3031
- name: Use Node.js
31-
uses: actions/setup-node@v4
32+
uses: actions/setup-node@v5
3233
with:
3334
cache: "npm"
35+
node-version: 22
3436
- run: npm install --ignore-scripts --no-audit --no-fund
3537
- run: npm run check
3638

@@ -39,11 +41,12 @@ jobs:
3941
runs-on: ubuntu-latest
4042
steps:
4143
- name: Checkout code
42-
uses: actions/checkout@v4
44+
uses: actions/checkout@v5
4345
- name: Use Node.js
44-
uses: actions/setup-node@v4
46+
uses: actions/setup-node@v5
4547
with:
4648
cache: "npm"
49+
node-version: 22
4750
- run: npm install --ignore-scripts --no-audit --no-fund
4851
- name: Build package
4952
run: npm run build

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"default": "./dist/css-design-tokens.js"
2727
},
2828
"engines": {
29-
"node": ">=18"
29+
"node": ">=22"
3030
},
3131
"scripts": {
3232
"test": "vitest run",

src/destructure-line-height.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test('percentage', () => {
2222

2323
test('number', () => {
2424
expect.soft(destructure_line_height('1')).toEqual(1)
25+
expect.soft(destructure_line_height('1.0')).toEqual(1)
2526
expect.soft(destructure_line_height('1.1')).toEqual(1.1)
2627
expect.soft(destructure_line_height('1e2')).toEqual(100)
2728
})
@@ -36,6 +37,15 @@ test('length', () => {
3637
expect.soft(destructure_line_height('1e2em')).toEqual({ value: 100, unit: 'em' })
3738
})
3839

40+
test('zero', () => {
41+
expect.soft(destructure_line_height('0%')).toEqual(0)
42+
expect.soft(destructure_line_height('0.0%')).toEqual(0)
43+
expect.soft(destructure_line_height('0px')).toEqual(0)
44+
expect.soft(destructure_line_height('0.0px')).toEqual(0)
45+
expect.soft(destructure_line_height('0')).toEqual(0)
46+
expect.soft(destructure_line_height('0.0')).toEqual(0)
47+
})
48+
3949
test('unprocessable values', () => {
4050
expect.soft(destructure_line_height('var(--my-line-height)')).toEqual(null)
4151
expect.soft(destructure_line_height('var(--my-line-height, 1.2)')).toEqual(null)

src/destructure-line-height.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ export function destructure_line_height(value: string): Length | number | null {
2121

2222
switch (maybe_dimension.type) {
2323
case 'Dimension': {
24+
let value = Number(maybe_dimension.value)
25+
if (value === 0) {
26+
return 0
27+
}
2428
return {
25-
value: Number(maybe_dimension.value),
29+
value,
2630
unit: maybe_dimension.unit
2731
}
2832
}

0 commit comments

Comments
 (0)