Skip to content

Extract rule: template-template-length#2624

Merged
NullVoxPopuli merged 1 commit intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-template-length
Mar 19, 2026
Merged

Extract rule: template-template-length#2624
NullVoxPopuli merged 1 commit intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-template-length

Conversation

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

Split from #2371.

Copy link
Copy Markdown

@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-template-length

Compared against ember-template-lint template-length.js.

General Correctness

  1. 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 default max: 200 / min: 5 thresholds 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.

  2. Error message: The messages use the same format as the original: Template length of ${length} exceeds ${max} and Template 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}.

  3. GlimmerTemplate:exit node: The port uses GlimmerTemplate:exit which is the ESLint way to handle template-level analysis. This is correct for the ESLint paradigm.

  4. Config parsing: The port correctly replicates the original's config parsing logic for boolean, object (with min/max integer keys), and undefined cases. The validation via isValidConfigObjectFormat matches the original.

  5. parseConfig error handling: The port throws an error for invalid config, similar to the original. However, the original uses createErrorMessage helper for a formatted error message, while the port uses a simpler string. This is fine.

  6. Tests: The tests verify both min and max constraints. However, given the line-count semantics, the test values (like min: 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

@NullVoxPopuli NullVoxPopuli merged commit 498837e into ember-cli:master Mar 19, 2026
9 checks passed
@NullVoxPopuli NullVoxPopuli deleted the nvp/template-lint-extract-rule-template-template-length branch March 19, 2026 17:30
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