Extract rule: template-style-concatenation#2622
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-style-concatenation
Compared against ember-template-lint style-concatenation.js.
General Correctness
-
Faithful port: The logic correctly mirrors the original. The original checks
ElementNodefor astyleattribute whose value is either aConcatStatementor aMustacheStatementwith aconcathelper path. The ESLint port does the same with the appropriate Glimmer-prefixed AST node types. Good. -
Error message difference: The original uses
'Concatenated styles must be marked as \htmlSafe`.'but the ESLint port uses'Avoid string concatenation in style attributes. Use a computed property with htmlSafe instead.'. This is a meaningful difference in messaging. The original's message is more specific and actionable (telling users to usehtmlSafe`). The port's message is more prescriptive (suggesting computed properties). Consider aligning with the original message for consistency, or at least noting the intentional change. -
Attribute finding approach: The original uses
AstNodeInfo.findAttribute(node, 'style')while the port usesnode.attributes?.find((a) => a.name === 'style'). These are functionally equivalent. Good. -
Tests: Good coverage for both gjs and hbs modes. The test cases cover
ConcatStatement(interpolated strings likestyle="color: {{this.color}}") andMustacheStatementwithconcathelper. Valid cases correctly includehtml-safewrapping aroundconcat.
Scope Analysis (gjs/gts)
This rule checks path.original === 'concat' to detect the concat helper used in style attributes. In gjs/gts, concat could theoretically be shadowed by a local import. However, the concat helper is a very common Ember built-in, and the rule is specifically checking for it within a style attribute's mustache value -- a very specific context. The risk of false positives from shadowing is minimal. That said, for completeness, scope analysis could verify that concat refers to the built-in, but this is low priority.
🤖 Automated review comparing with ember-template-lint source
Split from #2371.