Extract rule: template-quotes#2598
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-quotes (PR #2598)
Comparison with ember-template-lint quotes.js
General correctness:
-
Schema matches original config: The original accepts
'double','single', or{ curlies, html }object. The PR's schema correctly models this withoneOf: [enum, object]. Good. -
AttrNode handling: The original uses
node.quoteType === badChars.htmlto detect wrong quotes, which relies on the AST providing aquoteTypeproperty. The PR instead extracts the raw source text and looks for the quote character after=. This is a reasonable workaround since the Glimmer ESLint AST may not exposequoteType. However, potential issue: if an attribute value is a MustacheStatement (e.g.,class={{something}}), the raw text approach could behave unexpectedly. The PR doesn't explicitly filter these out — it relies onafterEq !== badChars.htmlto skip them (since{is not a quote char). This should work in practice. -
Fix approach: The original uses
node.quoteType = goodChars.html(direct AST mutation via ember-template-recast). The PR usesfixer.replaceTexton the raw source. This is the correct ESLint approach. The fix looks correct — it replaces the outer quotes while preserving the inner content. -
StringLiteral handling: Correctly checks
raw[0](first char of source text) against the bad quote char. Fix replaces outer quotes. Matches original logic. -
Missing gjs-specific invalid tests: The
ruleTester(gjs mode) has valid tests butinvalid: []is empty. All invalid tests are only in the hbs tester. Consider adding at least one or two invalid gjs test cases for completeness, e.g.,<template><div class='foo'></div></template>with the default "double" config.
Scope analysis (gjs/gts):
This rule is purely about quote style — it checks GlimmerAttrNode and GlimmerStringLiteral for syntactic/stylistic properties (which quote character is used). No helper/component name matching involved. No scope analysis needed.
Overall: Good migration. The main suggestion is to add some invalid gjs test cases for better coverage.
🤖 Automated review comparing with ember-template-lint source
974002c to
164ac58
Compare
Split from #2371.