Extract rule: template-table-groups#2623
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-table-groups
Compared against ember-template-lint table-groups.js.
General Correctness
-
Faithful port: This is a complex rule and the port does a thorough job. The core logic -- checking that
<table>elements only contain allowed table grouping children (caption,colgroup,thead,tbody,tfoot) in the correct order, with control flow transparency -- is well implemented. -
Empty table handling: The port adds special handling for truly empty tables (lines 279-288) by parsing the source text to detect self-closing-like patterns. The original ETL rule does NOT have this explicit check -- it would just iterate over an empty children array and not report. This means the ESLint port is stricter than the original for empty
<table></table>. In the original,<table></table>would not trigger an error because the children array is empty and the loop simply doesn't execute. Verify whether this added strictness is intentional. -
dasherizefunction: The port implements its owndasherize()using regex. The original importsdasherizeComponentNamefrom a helper. The port's implementation converts::to/and camelCase to kebab-case, which matches the expected behavior for Ember component name conversion. Looks correct. -
isControlFlowHelperlist: The port includes['if', 'unless', 'each', 'each-in', 'let', 'with'], which matches the original'sAstNodeInfo.isControlFlowHelper(). Good. -
Control flow scoping for if/unless branches: The original uses
scopedIndicesas a stack and, onCONTROL_FLOW_START_MARK, creates a new set by reducing all scoped indices. The ESLint port instead creates a copy of just the current set:new Set(currentAllowedMinimumIndices). This is a behavioral difference from the original. The original merges ALL parent scopes into the new scope, while the port only copies the current scope. For nested control flow with if/else branches, this could produce different results. Consider aligning with the original'sreduceapproach. -
Tests: Excellent coverage -- 893 lines of tests covering valid/invalid cases, control flow, ordering, custom component mappings via options, and both gjs and hbs modes. The test suite is comprehensive and well-structured.
-
Schema alignment: The schema correctly uses the same
allowed-*-componentskeys as the original's configuration. Good.
Scope Analysis (gjs/gts)
This rule checks structural properties: HTML tag names (table, thead, etc.), attribute names (@tagName), and control flow helper names (if, unless, each, etc.). It also checks node.path?.original === 'yield' for the {{yield}} keyword. All of these are Ember built-in keywords or HTML structural elements. No scope analysis needed -- shadowing yield, if, unless, etc. in JS would be extremely unusual and not a realistic concern.
🤖 Automated review comparing with ember-template-lint source
Split from #2371.