Extract rule: template-sort-invocations#2620
Extract rule: template-sort-invocations#2620NullVoxPopuli wants to merge 3 commits intoember-cli:masterfrom
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-sort-invocations
Compared against ember-template-lint sort-invocations.js.
General Correctness
-
reportedflag limits to one error per file: The rule uses alet reported = falseflag that prevents reporting more than one sorting violation per file. The original ETL rule does NOT have this behavior -- it reports all violations found across all nodes. This means if a file has multiple unsorted elements, the ESLint rule will only report the first one. This is a behavioral difference from the original. Was this intentional? If so, it should be documented. If not, thereportedguard should be removed. -
No autofix: The original ETL rule has full
fixmode support (sorting attributes, modifiers, hash pairs, and reordering splattributes). The ESLint port setsfixable: null. This is a significant feature loss. The original marks all violations asisFixable: true. Consider implementing autofix or at least noting this limitation in the docs. -
localeComparevs simple string comparison: The ESLint port usesnameA.localeCompare(nameB)while the original uses simple>/<string comparison. This could produce different sort orders for non-ASCII attribute names. The original's behavior is more predictable (pure lexicographic). This is a minor behavioral difference but could cause inconsistencies between the two tools. -
GlimmerStringLiteralfield name: IncompareModifiers, the port accesseseventA.valueforGlimmerStringLiteralnodes, while the original accesseseventA.originalforStringLiteralnodes. Verify thatvalueis the correct property onGlimmerStringLiteralnodes in the ember-eslint-parser -- it might beoriginalorvaluedepending on the parser. -
canSkipSplattributesLastlogic difference: The original checksattributes.at(-1)andmodifiers.at(-1)without first checking array lengths. The ESLint port adds extra guards for empty arrays, which is good defensive coding. However, the original also doesn't have theattributes.length === 1special-case message logic that the port adds. The port reportsattributeOrderwhen...attributesis the only attribute, vs.splattributesOrderotherwise. This is a nice UX improvement. -
Comprehensive test coverage: The tests cover the main scenarios well. Good to see both gjs and hbs tests.
Scope Analysis (gjs/gts)
This rule only checks structural properties: attribute names, attribute ordering, modifier ordering, hash pair ordering. It does not match any helper/component names by string. No scope analysis needed.
🤖 Automated review comparing with ember-template-lint source
The rule had a `reported` flag that, once set to true, prevented any further errors from being reported in the same file. The original ember-template-lint rule reports all out-of-order invocations, not just the first one. Remove the flag so all violations are reported. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…errors Fix one-error-per-file limitation in template-sort-invocations
Split from #2371.