feat: v2 migration rules in ValidatePlugin + DOM hook deprecations#722
Conversation
- Add migration detection rules to ValidatePlugin: missing-template-params-plugin, missing-alias-sorting-plugin, deprecated-prop-children, deprecated-prop-hid-vmid, deprecated-prop-body - Mark dom:renderTag and dom:rendered hooks as @deprecated in types - Add @unhead/vue/legacy deprecation shim with re-export from client Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
π WalkthroughWalkthroughAdds v2βv3 migration validation rules and deprecation warnings, marks two DOM hooks deprecated in types, expands unit tests for migration validations, and introduces a legacy Vue export that re-exports the client with a runtime deprecation notice. Changes
Sequence Diagram(s)(omitted) Estimated code review effortπ― 3 (Moderate) | β±οΈ ~20 minutes Possibly related PRs
Poem
π₯ Pre-merge checks | β 2 | β 1β Failed checks (1 warning)
β Passed checks (2 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ§ͺ 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 |
Bundle Size Analysis
|
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/unhead/src/plugins/validate.ts`:
- Around line 578-579: The current check "'body' in tag.props" triggers the
deprecation warning even for body: false; narrow it to only match the legacy
case by changing the condition to check for strict true (e.g. tag.props.body ===
true) before calling report('deprecated-prop-body', ...). Update the condition
around the report call in the validate plugin so only tags with body set to true
emit the deprecation warning.
πͺ 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: add0bad8-88ec-4e76-b803-53d44064a6fe
π Files selected for processing (1)
packages/unhead/src/plugins/validate.ts
Addresses CodeRabbit review β `'body' in tag.props` triggered false positives for `body: false`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Recommends using ValidatePlugin during v2βv3 upgrade to detect deprecated props, missing TemplateParamsPlugin/AliasSortingPlugin, and other common migration issues. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@MIGRATION.md`:
- Line 41: The TOC anchors for the "Schema.org Plugin" heading are incorrect
(they use "schema-org"); update the fragment(s) in the MIGRATION.md TOC to match
the markdown-generated anchor (remove the period so "Schema.org" becomes
"schemaorg"), e.g. change links referencing "schema-org" to "schemaorg" (and
similarly adjust any combined fragments like "schema-org-plugin" to
"schemaorg-plugin"), apply the same fixes for the second occurrence noted, and
re-run markdownlint (MD051) to verify the link-fragments are resolved.
- Around line 196-209: The "Vue Legacy Exports" section incorrectly says the
`/legacy` export path "has been removed" but the PR actually reintroduces it
with a deprecation shim; update this section to state that `@unhead/vue/legacy`
is reintroduced as a deprecated compatibility shim that re-exports from
`@unhead/vue/client` (see packages/vue/src/legacy.ts) and emits a runtime
`console.warn` deprecation notice, or alternatively remove the section if the
intent is to stop supporting itβensure the text references the re-export and
deprecation behavior so it matches the code 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: ad41fdf7-d082-4c03-a62f-6b6125c87239
π Files selected for processing (1)
MIGRATION.md
- Detect `mode` option on head.push() (silently ignored in v3) - Fix MIGRATION.md: /legacy is deprecated not removed - Fix Schema.org anchor links in TOC - Fix dom:rendered @deprecated JSDoc wording
π Linked issue
Resolves #711
β Type of change
π Description
Mitigates v3 breaking changes that were not previously deprecated in v2. Adds runtime migration detection to
ValidatePluginso users upgrading get actionable warnings instead of silent breakage.ValidatePlugin migration rules (
packages/unhead/src/plugins/validate.ts):missing-template-params-pluginβ warns whentemplateParamsentries exist butTemplateParamsPluginis not registeredmissing-alias-sorting-pluginβ warns whenbefore:/after:tag priorities are used butAliasSortingPluginis not registereddeprecated-prop-childrenβ detects legacychildrenprop (should beinnerHTML)deprecated-prop-hid-vmidβ detects legacyhid/vmidprops (should bekey)deprecated-prop-bodyβ detects legacybody: trueprop (should betagPosition: 'bodyClose')deprecated-option-modeβ detects removedmodeoption onhead.push()callsAll rules follow the existing ESLint-style config pattern and can be individually set to
'off'.DOM hook deprecations (
packages/unhead/src/types/hooks.ts):dom:renderTagβ marked@deprecated(not called internally, will be removed in v4)dom:renderedβ marked@deprecated(DOM rendering is synchronous, will be removed in v4)Vue legacy shim (
packages/vue/src/legacy.ts):@unhead/vue/legacyexport path with aconsole.warndeprecation notice@unhead/vue/clientso existing imports continue workingMigration guide (
MIGRATION.md):