✨ Recognised the @gift theme data global in v6#840
Conversation
Ghost 6 exposes `@gift` to themes via the gift-links reader route, so
themes can build their own gift-link reader UI with {{#if @gift}} and
{{@gift.post_id}}. Without this, GS120-NO-UNKNOWN-GLOBALS flagged it as
an unknown global.
`@gift` only exists in Ghost 6, so it's a version-scoped global rather
than a flat allowlist entry: the active spec's `knownGlobals` is now
threaded through the AST linter into the scope's allowlist check. v6
adds `gift`; v5 still (correctly) flags it, since a v5-targeting theme
using @gift would break on Ghost 5. Mirrors how `pageBuilderProperties`
is defined per-spec.
Refs https://linear.app/ghost/issue/BER-3738
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
WalkthroughThe PR introduces a Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
What
Teaches gscan that
@giftis a known template data global in Ghost 6, so themes building their own gift-link reader UI with{{#if @gift}}/{{@gift.post_id}}don't fail validation with aGS120-NO-UNKNOWN-GLOBALS("not a known global") error.Ghost 6 exposes
@giftto themes via the gift-links reader route (/g/<slug>). This should land before the feature is documented so theme authors writing@gifttemplates don't hit false errors.Why version-scoped (v6 only)
@giftonly exists in Ghost 6. A v5-targeting theme using@giftwould break on Ghost 5, so it's a version-scoped global rather than a flat allowlist entry — v6 recognises it, v5 still (correctly) flags it.This mirrors how
pageBuilderPropertiesis defined per-spec: the active spec's newknownGlobalslist is threaded through the AST linter into the scope's allowlist check.lib/specs/v6.js—knownGlobals: _.union(previousSpec.knownGlobals, ['gift'])lib/specs/v5.js—knownGlobals: []lib/checks/120-no-unknown-globals.js→lib/ast-linter/linter.js→lib/ast-linter/rules/base.js→lib/ast-linter/rules/internal/scope.js—knownGlobalsflows intonew Scope({extraGlobals})The shared base allowlist (
site/member/etc.) stays inscope.js;knownGlobalsis purely additive per version.Tests
test/fixtures/themes/120-no-unknown-globals/v5/with-gift/(uses{{#if @gift}}+{{@gift.post_id}})@giftis flagged (2 failures)Downstream (separate)
gscan is a published package — this does not change in-product theme validation until Ghost core bumps its
gscandependency to the release that includes this. That bump is a follow-up once this is released.Refs https://linear.app/ghost/issue/BER-3738