Skip to content

Extract rule: template-no-yield-to-default#2597

Merged
NullVoxPopuli merged 2 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-yield-to-default
Mar 20, 2026
Merged

Extract rule: template-no-yield-to-default#2597
NullVoxPopuli merged 2 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-yield-to-default

Conversation

@NullVoxPopuli
Copy link
Contributor

Split from #2371.

Copy link

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent left a comment

Choose a reason for hiding this comment

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

Review: template-no-yield-to-default (PR #2597)

Comparison with ember-template-lint no-yield-to-default.js

General correctness:

  1. Good coverage: The rule correctly handles both yield to="default" (via GlimmerMustacheStatement) and block-param keywords like has-block "default", has-block-params "default", hasBlock "default", hasBlockParams "default" (via both GlimmerMustacheStatement and GlimmerSubExpression). This matches the original's scope.

  2. Different error messages: The original uses a single message 'A block named "default" is not valid' for all cases. The PR uses two different messages: noYieldToDefault for the yield case and noExplicitDefaultBlock for the block-param-keyword case. This is actually an improvement in clarity — the two messages give more specific guidance.

  3. Report node difference: The original reports on toHashPair (the hash pair node) for yield cases and toParam (the string literal) for block-param cases. The PR reports on the entire node (the MustacheStatement) for yield cases and the entire node for block-param cases. This means the error location/range will be different (broader). Not incorrect, but a deliberate choice worth noting.

  4. Tests are thorough: Both gjs and hbs modes tested. SubExpression cases (e.g., {{if (has-block "default")}} and {{#if (has-block "default")}}{{/if}}) are covered.

Scope analysis (gjs/gts):

  • yield is a Glimmer keyword — cannot be shadowed.
  • has-block, has-block-params, hasBlock, hasBlockParams are Glimmer keywords — cannot be shadowed by JS imports.

No scope analysis needed.

Overall: Clean, thorough migration with improved error messages. Looks good.

🤖 Automated review comparing with ember-template-lint source

@NullVoxPopuli NullVoxPopuli force-pushed the nvp/template-lint-extract-rule-template-no-yield-to-default branch from b192bef to cb105f8 Compare March 20, 2026 21:40
@NullVoxPopuli NullVoxPopuli merged commit d87b305 into ember-cli:master Mar 20, 2026
9 checks passed
@NullVoxPopuli NullVoxPopuli deleted the nvp/template-lint-extract-rule-template-no-yield-to-default branch March 20, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants