Extract rule: template-simple-unless#2619
Extract rule: template-simple-unless#2619NullVoxPopuli wants to merge 1 commit intoember-cli:masterfrom
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-simple-unless
Compared against ember-template-lint simple-unless.js.
General Correctness
-
Missing inline
unlesswith helper detection (default maxHelpers=1): In the original ETL rule, inline{{unless}}mustache statements with a sub-expression first param are checked via_withHelper. In the ESLint port, theGlimmerMustacheStatementhandler checksnode.params?.[0]?.path, but this condition is only true when the first param is a sub-expression with its own.path. This appears correct for the intended use case -- good. -
Missing valid cases for inline
unlessin gjs tests: The gjsvalidtests are missing several cases that the hbs tests include, such as{{unless foo bar}},{{unless (eq foo bar) baz}},{{unless (and isBad isAwful) "notBadAndAwful"}}, and theallowlist/maxHelperscombination tests. These should be added for completeness. -
Missing invalid cases for inline
unlessin gjs tests: Several inline{{unless}}invalid cases are only tested in hbs mode but not in gjs mode (e.g.,{{unless (if (or true)) 'Please no'}}with default maxHelpers). Consider adding them. -
else unlessdetection usingsourceCode.getText(): TheisElseUnlessBlockfunction usessourceCode.getText(node)and checkstext.startsWith('{{else '). This is a reasonable approach for ESLint since there's nosourceForNodeequivalent, but it's worth noting this may be fragile if the parser represents{{else unless}}blocks differently than expected. Worth verifying this works correctly with the actual parser output. -
Original ETL has autofix support: The original rule supports
fixmode (convertingunlesstoif (not ...)and swapping else blocks). The ESLint port does not implementfixable. This is noted for awareness -- it's fine to skip for an initial port, but theisFixablemetadata in the ETL messages suggests this was an important feature. -
Message interpolation via
withHelpermessageId: ThewithHelpermessage template is'{{message}}', which works but is unusual. Typically ESLint rules usedatafor specific interpolation fields rather than passing the entire message string. Consider using separate messageIds for the differentwithHelpersub-cases (maxHelpers exceeded, allowlist violation, denylist violation).
Scope Analysis (gjs/gts)
This rule checks node.path.original === 'unless' and node.path.original === 'if'. These are Ember/Handlebars built-in control flow keywords. In gjs/gts, unless is not a JavaScript keyword and would be very unusual to shadow as a local variable. Similarly for if. No scope analysis needed -- these are structural/syntactic checks on Handlebars control flow constructs.
🤖 Automated review comparing with ember-template-lint source
Split from #2371.