Commit 703bf15
committed
fix: ignore comment + whitespace nodes in template-no-yield-only
The rule flagged yield-only templates by asserting
`templateNodes.length === 1 && isYieldOnly(templateNodes[0])`. That
works only while the parser strips template comments out of the body,
which ember-estree 0.4.2 happened to do. Upstream ember-estree 0.4.3
(#31) began keeping MustacheCommentStatement nodes in the body, so a
template like
<template>{{! some comment }}{{yield}}</template>
now yields a body of length 2 and silently stops being flagged — which
is also why PR #2735 (upgrade to ember-eslint-parser 0.11) fails this
rule's CI.
Ignoring comment and whitespace-only text nodes before the length check
aligns with:
- upstream ember-template-lint's `no-yield-only.js` (unchanged there
since comments-in-body is the native Glimmer AST shape anyway)
- the sibling rule `template-no-bare-yield.js`, which already uses the
same `isEmptyNode` filter
The fix is a no-op on the currently-pinned ember-eslint-parser@0.10 and
fixes the rule under any parser version that preserves comment nodes in
the template body. The rule also now correctly catches yield-only
templates that contain HTML comments (`<!-- x -->{{yield}}`), which it
was silently missing before.1 parent 7676bb3 commit 703bf15
2 files changed
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
1 | 9 | | |
2 | 10 | | |
3 | 11 | | |
| |||
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
47 | | - | |
| 55 | + | |
| 56 | + | |
48 | 57 | | |
49 | 58 | | |
50 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| |||
0 commit comments