Skip to content

build(deps): migrate @casl/ability v7 + @casl/vue v3#4199

Merged
PierreBrisorgueil merged 2 commits into
masterfrom
chore/casl-v7-migration
May 22, 2026
Merged

build(deps): migrate @casl/ability v7 + @casl/vue v3#4199
PierreBrisorgueil merged 2 commits into
masterfrom
chore/casl-v7-migration

Conversation

@PierreBrisorgueil
Copy link
Copy Markdown
Collaborator

Summary

Migrates @casl/ability ^6.8.1^7.0.0 and @casl/vue ^2.2.6^3.0.0 together. Supersedes dependabot #4194 + #4195 (each red on its own — they must move together).

Why bump both together

@casl/vue@2 rejects @casl/ability@^7 as a peer (build breaks → #4194), and @casl/vue@3 requires @casl/ability@^7.

What changed

  • package.json@casl/ability ^7.0.0 + @casl/vue ^3.0.0.
  • src/lib/helpers/ability.jsdropped Vue's reactive() around the ability. v7 freezes the ability's internal rule structures, so a reactive() proxy over the frozen rules array throws a Proxy get-invariant TypeError on the first .can() call. Components call ability.can() directly in computeds, so reactivity is preserved via a local toReactiveAbility() helper that tracks the ability's updated event through a ref read in possibleRulesFor. This mirrors @casl/vue's internal reactiveAbility, which v3 declares in its .d.ts but does not export at runtime.
  • MIGRATIONS.md — downstream-complete upgrade notes.

No change to src/main.js (abilitiesPlugin API preserved) or the subject() helper.

Test plan

  • npm run lint — clean
  • npm run test:unit — 1910 passed (incl. the ability helper test that threw the Proxy TypeError pre-fix)
  • npm run build — passes (validates @casl/vue v3 ESM import resolution)
  • CI Playwright E2E — validates auth/permission reactivity in the real app

Bump both together — @casl/vue@2 rejects @casl/ability@^7 as a peer (build
breaks), @casl/vue@3 requires it. v7 freezes the ability's internal rule
structures, so wrapping it in Vue's reactive() throws a Proxy get-invariant
TypeError on the first .can() call. Wrap with a local toReactiveAbility() helper
that tracks the `updated` event via a ref read in possibleRulesFor, keeping
component computeds reactive. Mirrors @casl/vue's internal reactiveAbility,
which v3 declares in its types but does not export at runtime.

Supersedes dependabot #4194, #4195. See MIGRATIONS.md for downstream notes.
Copilot AI review requested due to automatic review settings May 22, 2026 13:18
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 10 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f109da89-1760-49f0-841e-6d567c9f3ace

📥 Commits

Reviewing files that changed from the base of the PR and between c053c37 and 0ee1bfd.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • MIGRATIONS.md
  • package.json
  • src/lib/helpers/ability.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/casl-v7-migration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates CASL dependencies to the required compatible pair (@casl/ability@7 + @casl/vue@3) and updates the shared Vue ability helper to avoid Vue reactive() proxies over CASL v7’s frozen rule internals.

Changes:

  • Bump @casl/ability to ^7.0.0 and @casl/vue to ^3.0.0 (must move together due to peer requirements).
  • Replace reactive(createMongoAbility([])) with a local toReactiveAbility() wrapper that drives Vue reactivity via the ability’s updated event.
  • Add downstream upgrade notes to MIGRATIONS.md.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/lib/helpers/ability.js Introduces toReactiveAbility() and switches the exported singleton ability to use it instead of Vue reactive().
package.json Updates CASL dependency versions to @casl/ability@^7.0.0 and @casl/vue@^3.0.0.
package-lock.json Locks updated CASL versions and transitive @ucast/* upgrades.
MIGRATIONS.md Documents the coordinated CASL upgrade and downstream actions.

Comment thread src/lib/helpers/ability.js
Comment thread MIGRATIONS.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.56%. Comparing base (c053c37) to head (0ee1bfd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4199   +/-   ##
=======================================
  Coverage   99.56%   99.56%           
=======================================
  Files          31       31           
  Lines        1140     1151   +11     
  Branches      329      329           
=======================================
+ Hits         1135     1146   +11     
  Misses          5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Review (Copilot): the reactive wrapper overrode possibleRulesFor but only
forwarded (action, subject), dropping CASL's optional `field` arg — silently
breaking field-level permission checks. Forward all args via (...args). Also
corrects the MIGRATIONS wording (v7 renames PureAbility→Ability, doesn't remove
it) and drops the stale `reactiveAbility` reference (not exported at runtime).
@PierreBrisorgueil PierreBrisorgueil merged commit bfb3edd into master May 22, 2026
7 checks passed
@PierreBrisorgueil PierreBrisorgueil deleted the chore/casl-v7-migration branch May 22, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants