Added recursive layout detection to v6#816
Conversation
WalkthroughThis PR implements a new theme validation check Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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 |
85debbc to
4ebe6a1
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test/130-template-inheritance.test.js (1)
1-46:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReplace
shouldassertions with Vitestexpectintest/130-template-inheritance.test.js.This file uses
require('should')andoutput.should.../failure.message.should...assertions; update them to vitest’sexpect(...)style per the test guidelines.🤖 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/130-template-inheritance.test.js` around lines 1 - 46, Update the test file to replace all "should" style assertions with Vitest "expect" assertions: remove the require('should') line, import Vitest's expect if not global, and change checks on output and results to expect(output).toBeValidThemeObject() (or the appropriate custom matcher), expect(Object.keys(output.results.fail)).toEqual([ruleCode]), expect(output.results.fail).toEqual({}) / expect(output.results.pass).toContain(ruleCode) as applicable, and change failure.message.should.containEql(...) to expect(failure.message).toContain(...) and failure.ref.should.eql('default.hbs') to expect(failure.ref).toEqual('default.hbs'); update all uses of thisCheck, output, failure, and ruleCode accordingly so assertions use expect(...) with toEqual/toContain/toBe... matchers.
🤖 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 `@AGENTS.md`:
- Around line 105-114: Update the examples under "Common Test Patterns" to use
vitest's global expect assertions instead of the legacy should style: replace
the `check(...)` usage examples so that the passing test asserts the results
array with expect(theme.results.pass).toContain('GS010-PJ-REQ') (using check and
themePath to locate the theme) and the failing test asserts the specific failure
key with expect(theme.results.fail['GS010-PJ-NAME-REQ']).toBeDefined() or
toBeTruthy(); keep using the same helpers (`check`, `themePath`) and the same
result properties (`theme.results.pass`, `theme.results.fail`) but swap out
`.should.*` expressions for the equivalent `expect(...).toContain` /
`expect(...).toBeDefined` style.
- Around line 162-177: The example exported check function checkSomething is
missing the required third parameter themePath; update its signature to accept
(theme, options, themePath) and ensure it returns a Promise (make it async if
needed), and if options or themePath are unused add the appropriate
eslint-disable comment as noted in the guidelines so the linter won't complain.
- Around line 193-204: Update the test example in the
`test/XXX-check-name.test.js` snippet to use vitest's expect-style assertions
instead of the deprecated should library: keep the existing test structure and
the call to utils.testCheck(checkSomething, 'XXX-check-name/failing-case'), but
replace the old "output.results.fail['GSXXX-ERROR-CODE'].should.exist()"
assertion with a vitest expect assertion (e.g.,
expect(output.results.fail['GSXXX-ERROR-CODE']).toBeDefined() or another
appropriate expect matcher) so it matches the project's vitest examples and
style.
In `@lib/checks/130-template-inheritance.js`:
- Around line 137-154: The exported check function checkTemplateInheritance
currently is a synchronous two-arg function (checkTemplateInheritance(theme,
options)) but must follow the check-module contract: change it to an async
function with signature async function checkTemplateInheritance(theme, options,
themePath) (or equivalent arrow) so it returns a Promise that resolves to theme;
keep the existing logic intact, accept the extra themePath parameter (even if
unused) and ensure the module still exports checkTemplateInheritance so callers
receive a Promise.
---
Outside diff comments:
In `@test/130-template-inheritance.test.js`:
- Around line 1-46: Update the test file to replace all "should" style
assertions with Vitest "expect" assertions: remove the require('should') line,
import Vitest's expect if not global, and change checks on output and results to
expect(output).toBeValidThemeObject() (or the appropriate custom matcher),
expect(Object.keys(output.results.fail)).toEqual([ruleCode]),
expect(output.results.fail).toEqual({}) /
expect(output.results.pass).toContain(ruleCode) as applicable, and change
failure.message.should.containEql(...) to expect(failure.message).toContain(...)
and failure.ref.should.eql('default.hbs') to
expect(failure.ref).toEqual('default.hbs'); update all uses of thisCheck,
output, failure, and ruleCode accordingly so assertions use expect(...) with
toEqual/toContain/toBe... matchers.
🪄 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: f4b0a8b8-a43b-4a7c-bcec-3e8457482a6e
📒 Files selected for processing (10)
AGENTS.mdlib/checks/130-template-inheritance.jslib/specs/v6.jstest/130-template-inheritance.test.jstest/checker.test.jstest/fixtures/themes/130-template-inheritance/indirect-cycle/default.hbstest/fixtures/themes/130-template-inheritance/indirect-cycle/layouts/base.hbstest/fixtures/themes/130-template-inheritance/recursive-default/default.hbstest/fixtures/themes/130-template-inheritance/valid-default/default.hbstest/fixtures/themes/130-template-inheritance/valid-default/index.hbs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85debbc2a6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
4ebe6a1 to
59acb95
Compare
ref https://linear.app/ghost/issue/BER-3133
GS130-NO-RECURSIVE-LAYOUTrule to catch recursive{{!< ...}}template inheritance, includingdefault.hbsself-inheritance.