From 6c30c701bfe7f6301870891b0e39f1e6b42ae84b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 08:41:47 +0000 Subject: [PATCH] perf: use css-parser 0.19.6 CSSNode.for_each instead of for-of Co-Authored-By: Claude Sonnet 5.5 --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- src/lib/index.ts | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index d3276b0..2c5b8a7 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "knip": "knip" }, "dependencies": { - "@projectwallace/css-parser": "^0.19.0" + "@projectwallace/css-parser": "^0.19.6" }, "devDependencies": { "@projectwallace/preset-oxlint": "^0.0.11", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d94e206..e145fa1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@projectwallace/css-parser': - specifier: ^0.19.0 - version: 0.19.0 + specifier: ^0.19.6 + version: 0.19.6 devDependencies: '@projectwallace/preset-oxlint': specifier: ^0.0.11 @@ -567,8 +567,8 @@ packages: cpu: [x64] os: [win32] - '@projectwallace/css-parser@0.19.0': - resolution: {integrity: sha512-Sgb2uCRJbVfsEHbGaypNd8XnBcwtofc8vwDuxLrXXMQ1BeYT0X7Jr/DuFgbDX4cvQT9HusLXcNWT8JdjFzV/cw==} + '@projectwallace/css-parser@0.19.6': + resolution: {integrity: sha512-B59Rr+gS9bdr9NIMTBAxX8Ld4D66//zqe2ZD/zyeS0coZBP0+eJ6r2kXYDjGfnVJNo1GuD6eNOqglJLlCRdVlA==} engines: {pnpm: '>=11.0.0'} '@projectwallace/preset-oxlint@0.0.11': @@ -1687,7 +1687,7 @@ snapshots: '@oxlint/binding-win32-x64-msvc@1.89.0': optional: true - '@projectwallace/css-parser@0.19.0': {} + '@projectwallace/css-parser@0.19.6': {} '@projectwallace/preset-oxlint@0.0.11(oxlint@1.89.0)': dependencies: diff --git a/src/lib/index.ts b/src/lib/index.ts index 0d6d114..841d648 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -413,8 +413,8 @@ function print_selector_list( node: SelectorList | PseudoClassSelector | PseudoElementSelector, optional_space = SPACE, ): string { - let parts = [] - for (let child of node) { + let parts: string[] = [] + node.for_each((child) => { if (is_selector_list(child)) { parts.push(print_selector_list(child, optional_space)) } else { @@ -423,7 +423,7 @@ function print_selector_list( parts.push(',', optional_space) } } - } + }) return parts.join(EMPTY_STRING) } @@ -536,9 +536,9 @@ export function format( /** Prints a rule's selector list one selector per line, e.g. `.a,\n.b {`. */ function print_rule_selectors(node: SelectorList): string { - let lines = [] + let lines: string[] = [] let prev_end: number | undefined - for (let selector of node) { + node.for_each((selector) => { if (prev_end !== undefined) { let comment = get_comment(prev_end, selector.start) if (comment) { @@ -552,7 +552,7 @@ export function format( } lines.push(indent(depth) + printed) prev_end = selector.end - } + }) return lines.join(NEWLINE) } @@ -567,7 +567,7 @@ export function format( let prev_end: number | undefined - for (let child of node) { + node.for_each((child) => { if (prev_end !== undefined) { let comment = get_comment(prev_end, child.start) if (comment) { @@ -593,7 +593,7 @@ export function format( } prev_end = child.end - } + }) let comment_after_last = get_comment(prev_end, node.end) if (comment_after_last) { @@ -677,7 +677,7 @@ export function format( let prev_end: number | undefined - for (let child of node) { + node.for_each((child) => { if (prev_end !== undefined) { let comment = get_comment(prev_end, child.start, 0) if (comment) { @@ -700,7 +700,7 @@ export function format( lines.push(EMPTY_STRING) } } - } + }) let comment_after_last = get_comment(prev_end, node.end, 0) if (comment_after_last) {