Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/rules/template-no-whitespace-for-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ module.exports = {

return {
GlimmerTextNode(node) {
// Only flag body text, not attribute values. ember-eslint-parser
// emits attribute values as GlimmerTextNode children of a
// GlimmerAttrNode; skip those so only element body whitespace is
// checked.
if (node.parent?.type === 'GlimmerAttrNode') {
return;
}

const text = sourceCode.getText(node);
if (!text) {
return;
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/template-no-whitespace-for-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const validHbs = [
>
example
</div>`,
// Attribute values with consecutive spaces must not be flagged (false positive,
// cf. ember-template-lint#2899) — the rule targets element body text only.
'<div class="foo bar"></div>',
'<div style="margin: 0; padding: 0"></div>',
];

const invalidHbs = [
Expand Down
Loading