Extract rule: template-no-unnecessary-curly-parens#2587
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-no-unnecessary-curly-parens (comparing with ember-template-lint no-unnecessary-curly-parens)
Coverage
Good migration that captures the core behavior of the original rule.
What's done well
- Correct detection logic:
isFixableMustachechecks thatnode.pathis aGlimmerSubExpressionwith params or hash pairs, matching the original's check. - Auto-fix: Correctly reconstructs the mustache without the unnecessary parentheses.
- Good test coverage: Tests cover helpers with positional params, named params (hash), and the important edge case of parenthesized expressions inside
ConcatStatement(attribute interpolations like"{{index}}X{{(someHelper foo)}}"). - Both parser modes tested: gjs and hbs test sections included.
Items needing attention
-
Missing
ConcatStatementvisitor: The original rule has aConcatStatementvisitor that, in fix mode, iterates overnode.partsand fixes anyMustacheStatementparts that have unnecessary parens. The ESLint version only has aGlimmerMustacheStatementvisitor. This might still work if the ESLint parser emitsGlimmerMustacheStatementnodes inside concat statements (and the tests for<FooBar @x="{{index}}X{{(someHelper foo)}}" />do seem to pass), but it's worth verifying that the fix works correctly for these cases. The fact that the tests include these cases and pass is reassuring. -
{{(foo)}}/{{(this.helper)}}valid cases: These are correctly marked as valid -- when there are no params or hash pairs, the parens may serve a purpose (invoking a helper that returns a value). This matches the original. -
No
GlimmerBlockStatementhandling: The original only handlesMustacheStatement(andConcatStatement), so omitting block statement handling is correct and matches the original scope.
Verdict
Clean migration. The ConcatStatement visitor difference is worth noting, but the tests demonstrate the fix works in the concatenation context. No blocking issues.
🤖 Automated review comparing with ember-template-lint source
821a80f to
d1299c4
Compare
Split from #2371.