fix(deps): add support for unhead v3#795
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| link: [ | ||
| { | ||
| rel: props.loading === 'eager' ? 'preconnect' : 'dns-prefetch', | ||
| rel: (props.loading === 'eager' ? 'preconnect' : 'dns-prefetch') as 'preconnect', |
There was a problem hiding this comment.
is this correct? do we not support dns-prefetch as a rel value
There was a problem hiding this comment.
the type issue was from the .filter() / undefined href, these are both properly unionised
commit: |
📝 WalkthroughWalkthroughWiden Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Backstops @unhead/vue v3 compatibility while the default workspace install resolves to v2. Scoped pnpm override pins only this fixture to v3; e2e + typecheck regression tests skip when the workspace root is already on v3 (e.g. ecosystem-ci runs).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/unit/unhead-v3-typecheck.test.ts`:
- Around line 50-71: The test currently swallows exec failures by only copying
err.stdout/err.stderr, which can hide non-TypeScript failures; update the catch
block in the test (the exec(...) try/catch around nuxt typecheck) to fail the
test when the process rejects but parseTypecheckErrors(`${stdout}\n${stderr}`)
returns no diagnostics: after capturing stdout/stderr, if the caught error is
truthy and parseTypecheckErrors yields an empty array, rethrow the original
error or call expect.fail with the err so the test does not produce a false
negative; keep references to exec, parseTypecheckErrors, KNOWN_BASELINE_ERRORS
and newErrors to locate where to change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9dfeef9e-9b79-495b-b8de-a5b5a8f164da
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
package.jsonpnpm-workspace.yamltest/e2e/unhead-v3-compat.test.tstest/fixtures/unhead-v3/app.vuetest/fixtures/unhead-v3/nuxt.config.tstest/fixtures/unhead-v3/package.jsontest/unit/unhead-v3-typecheck.test.ts
✅ Files skipped from review due to trivial changes (1)
- test/fixtures/unhead-v3/package.json
| try { | ||
| const res = await exec('pnpm', ['exec', 'nuxt', 'typecheck'], { | ||
| cwd: fixtureDir, | ||
| env: { ...process.env, FORCE_COLOR: '0' }, | ||
| maxBuffer: 32 * 1024 * 1024, | ||
| }) | ||
| stdout = res.stdout | ||
| stderr = res.stderr | ||
| } | ||
| catch (err: any) { | ||
| stdout = err.stdout || '' | ||
| stderr = err.stderr || '' | ||
| } | ||
|
|
||
| const errors = parseTypecheckErrors(`${stdout}\n${stderr}`) | ||
| const newErrors = errors.filter(e => !KNOWN_BASELINE_ERRORS.has(e)) | ||
|
|
||
| expect(newErrors, [ | ||
| 'New type errors detected when typechecking the unhead-v3 fixture.', | ||
| 'Either: (a) fix the source so it compiles against @unhead/vue@^3, or', | ||
| '(b) add the error to KNOWN_BASELINE_ERRORS with a comment explaining why.', | ||
| ].join('\n')).toEqual([]) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ls -la
echo "--- file listing (target) ---"
ls -la test/unit/unhead-v3-typecheck.test.ts || true
echo "--- show file with line numbers (relevant range) ---"
nl -ba test/unit/unhead-v3-typecheck.test.ts | sed -n '1,220p'
echo "--- find parseTypecheckErrors definition/usages ---"
rg -n "function parseTypecheckErrors|parseTypecheckErrors\s*=" -S .
rg -n "parseTypecheckErrors\(" -S .
echo "--- find KNOWN_BASELINE_ERRORS definition ---"
rg -n "KNOWN_BASELINE_ERRORS" -S .
echo "--- find exec import/definition ---"
rg -n "import\s+\{\s*exec\s*\}|from ['\"].*['\"].*exec|exec\(" test/unit/unhead-v3-typecheck.test.ts
rg -n "from ['\"]child_process['\"][^;]*exec|promisify.*exec|function exec\(" -S .Repository: nuxt/scripts
Length of output: 1982
🏁 Script executed:
#!/bin/bash
set -u
FILE="test/unit/unhead-v3-typecheck.test.ts"
echo "--- show relevant range with line numbers (python) ---"
python3 - <<'PY'
from pathlib import Path
p = Path("test/unit/unhead-v3-typecheck.test.ts")
lines = p.read_text(encoding="utf-8").splitlines()
start, end = 1, 140
for i in range(start, min(end, len(lines)) + 1):
print(f"{i:4d} {lines[i-1]}")
PY
echo "--- show lines 40-100 exactly ---"
python3 - <<'PY'
from pathlib import Path
p = Path("test/unit/unhead-v3-typecheck.test.ts")
lines = p.read_text(encoding="utf-8").splitlines()
start, end = 35, 110
for i in range(start, min(end, len(lines)) + 1):
print(f"{i:4d} {lines[i-1]}")
PY
echo "--- find parseTypecheckErrors definition/usages ---"
rg -n "parseTypecheckErrors" test/unit -S
rg -n "function parseTypecheckErrors|const parseTypecheckErrors|let parseTypecheckErrors" -S .
echo "--- find KNOWN_BASELINE_ERRORS definition/usages ---"
rg -n "KNOWN_BASELINE_ERRORS" -S .
echo "--- find exec import/definition in the test file and nearby helpers ---"
rg -n "from ['\"][^'\"]+['\"]" test/unit/unhead-v3-typecheck.test.ts -S
rg -n "exec" test/unit/unhead-v3-typecheck.test.ts -S
rg -n "import\s+\{\s*exec\s*\}|from ['\"].*['\"]\s*;?|\bfunction exec\b|\bconst exec\b|\bexec\s*=" -S .Repository: nuxt/scripts
Length of output: 50369
Fail the test when nuxt typecheck rejects without producing TS diagnostics
The catch block only copies err.stdout/err.stderr into strings; if execFile fails for non-TypeScript reasons (no TS output), parseTypecheckErrors() returns [] (it filters only lines matching error TS\d+), making newErrors empty and the test pass as a false negative.
💡 Proposed fix
it('introduces no new type errors when compiled against `@unhead/vue`@^3', async () => {
let stdout = ''
let stderr = ''
+ let execError: unknown = null
try {
const res = await exec('pnpm', ['exec', 'nuxt', 'typecheck'], {
cwd: fixtureDir,
env: { ...process.env, FORCE_COLOR: '0' },
maxBuffer: 32 * 1024 * 1024,
@@
}
catch (err: any) {
+ execError = err
stdout = err.stdout || ''
stderr = err.stderr || ''
}
const errors = parseTypecheckErrors(`${stdout}\n${stderr}`)
+ if (execError && errors.length === 0) {
+ throw execError
+ }
const newErrors = errors.filter(e => !KNOWN_BASELINE_ERRORS.has(e))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/unit/unhead-v3-typecheck.test.ts` around lines 50 - 71, The test
currently swallows exec failures by only copying err.stdout/err.stderr, which
can hide non-TypeScript failures; update the catch block in the test (the
exec(...) try/catch around nuxt typecheck) to fail the test when the process
rejects but parseTypecheckErrors(`${stdout}\n${stderr}`) returns no diagnostics:
after capturing stdout/stderr, if the caught error is truthy and
parseTypecheckErrors yields an empty array, rethrow the original error or call
expect.fail with the err so the test does not produce a false negative; keep
references to exec, parseTypecheckErrors, KNOWN_BASELINE_ERRORS and newErrors to
locate where to change.
🔗 Linked issue
closes #703
📚 Description
this is an initial stab at making nuxt/scripts pass in ecosystem-ci with nuxt v4.5 (which contains unhead v3)
I've made a few guesses but feel free to scrap this!