Extract rule: template-template-length#2624
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-template-length
Compared against ember-template-lint template-length.js.
General Correctness
-
Length measurement difference: This is a significant behavioral difference. The original ETL rule measures template length by character count (
this.source.length), while the ESLint port measures by line count (node.loc.end.line - node.loc.start.line + 1). This means the defaultmax: 200/min: 5thresholds have completely different semantics:- Original: A template with 200+ characters triggers
tooLong - Port: A template with 200+ lines triggers
tooLong
A 200-character template is quite small (maybe 3-4 lines), while a 200-line template is substantial. This is a breaking behavioral change that will produce very different results. Users migrating from ETL would need to adjust their configuration values significantly. This should either be aligned with the original (character count) or clearly documented as an intentional change with guidance on equivalent threshold values.
- Original: A template with 200+ characters triggers
-
Error message: The messages use the same format as the original:
Template length of ${length} exceeds ${max}andTemplate length of ${length} is smaller than ${min}. However, since the unit changed from characters to lines, these messages could be confusing. Consider adding "lines" to the message, e.g.,Template length of ${length} lines exceeds ${max}. -
GlimmerTemplate:exitnode: The port usesGlimmerTemplate:exitwhich is the ESLint way to handle template-level analysis. This is correct for the ESLint paradigm. -
Config parsing: The port correctly replicates the original's config parsing logic for
boolean,object(withmin/maxinteger keys), andundefinedcases. The validation viaisValidConfigObjectFormatmatches the original. -
parseConfigerror handling: The port throws an error for invalid config, similar to the original. However, the original usescreateErrorMessagehelper for a formatted error message, while the port uses a simpler string. This is fine. -
Tests: The tests verify both
minandmaxconstraints. However, given the line-count semantics, the test values (likemin: 10,max: 3) are appropriate for line counting. The hbs tests also look correct.
Scope Analysis (gjs/gts)
This rule only measures template length (a structural/metric property). It does not match any helper or component names. No scope analysis needed.
🤖 Automated review comparing with ember-template-lint source
Split from #2371.