Skip to content

Extract rule: template-no-unused-block-params#2590

Merged
NullVoxPopuli merged 2 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-unused-block-params
Mar 21, 2026
Merged

Extract rule: template-no-unused-block-params#2590
NullVoxPopuli merged 2 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-unused-block-params

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-unused-block-params

Compared against the original ember-template-lint rule no-unused-block-params.

What's done well

  • Handles the key complexity of this rule well. Shadowing of block params in nested blocks, partial marking all outer params as used, and the "only trailing unused params" behavior are all correctly implemented.
  • Test coverage is thorough. All original test cases are ported, including shadowing ({{#each cats as |cat|}}{{#meow-meow cat as |cat|}}{{cat}}{{/meow-meow}}{{/each}}), component angle-bracket syntax (<BurgerMenu as |menu|>), curly syntax ({{#burger-menu as |menu|}}), and partial interaction.
  • The manual AST walking approach is a reasonable adaptation from the original's scope-based approach, since the ESLint Glimmer AST doesn't have the same scope frame infrastructure.

Observations and potential issues

  1. Error message semantics differ. The original reports: "'${unusedLocal}' is defined but never used", reporting a single unused param name. The new rule reports: "Block param \"${param}\" is unused" where param can be a comma-joined list of all trailing unused params (e.g., "item, index"). This is a behavioral difference -- the original reports one error per unused param, while the new rule reports one error per block statement with all trailing params joined. This could affect how users interact with the errors (e.g., suppressing individual params).

  2. Only trailing unused params are reported. The new rule intentionally only reports params after the last used one (matching the original's behavior). This is correct -- in Handlebars, you can't omit middle params, only trailing ones. Good.

  3. The ElementNode exit visitor from the original is not directly replicated. The original has both Block.exit and ElementNode.children.exit visitors. The new rule only listens for GlimmerBlockStatement. This appears correct because in the ESLint Glimmer AST, angle-bracket components yielding block params would still be represented as block statements. However, it's worth verifying that <BurgerMenu as |menu|> is indeed parsed as a GlimmerBlockStatement (the test cases suggest it is, since they pass).

  4. collectChildNodes is thorough in walking the AST -- it handles program, inverse, params, hash.pairs, body, path, attributes, and children. This covers the cases well.

  5. checkBlockParts function is defined after module.exports, which works in CommonJS but is a bit unusual. Minor style nit.

  6. No template-lint-disable test in gjs mode. The hbs tests include template-lint-disable comment cases from the original. These are valid in the hbs parser tests but the gjs tests don't test eslint-disable equivalents. Not a blocker, as eslint-disable is handled by ESLint core, not the rule itself.

Summary

This is one of the more complex rules to port due to scope tracking, and the implementation handles the complexity well. The main behavioral difference is the grouped error reporting for trailing params vs per-param errors. All original test scenarios are covered.


Automated review comparing with ember-template-lint source

@NullVoxPopuli NullVoxPopuli force-pushed the nvp/template-lint-extract-rule-template-no-unused-block-params branch from ee0730a to 66a70c1 Compare March 21, 2026 00:52
@NullVoxPopuli NullVoxPopuli merged commit f271c55 into ember-cli:master Mar 21, 2026
9 checks passed
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