Skip to content

Commit 92b6d17

Browse files
committed
Fix template-no-whitespace-for-layout false positive on attribute values
The rule's GlimmerTextNode visitor fired on attribute value text nodes (e.g. `<div class="foo bar">`), reporting layout-whitespace violations for consecutive spaces inside class lists and other attribute values. Upstream ember-template-lint only visits body text, since its HBS parser exposes attribute values differently. Skip GlimmerTextNodes whose parent is a GlimmerAttrNode.
1 parent b705850 commit 92b6d17

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/rules/template-no-whitespace-for-layout.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ module.exports = {
2727

2828
return {
2929
GlimmerTextNode(node) {
30+
// Upstream ember-template-lint only visits body text; its HBS parser
31+
// exposes attribute values as strings rather than TextNode children.
32+
// ember-eslint-parser emits them as GlimmerTextNode children of a
33+
// GlimmerAttrNode, so skip those to match upstream scope.
34+
if (node.parent?.type === 'GlimmerAttrNode') {
35+
return;
36+
}
37+
3038
const text = sourceCode.getText(node);
3139
if (!text) {
3240
return;

tests/lib/rules/template-no-whitespace-for-layout.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const validHbs = [
1818
>
1919
example
2020
</div>`,
21+
'<div class="foo bar"></div>',
22+
'<div class="min-h-dvh bg-gray-200 "></div>',
2123
];
2224

2325
const invalidHbs = [

0 commit comments

Comments
 (0)