From 58f498456c41a67142c7cdf95b69e600020e50a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Thu, 23 Apr 2026 10:50:08 +0200 Subject: [PATCH] fix: keep Glimmer comment nodes in body so root.find() can reach them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ember-estree's 0.4.2 contract removed Glimmer comment nodes from `GlimmerTemplate.body` and mirrored them into `ast.comments` as ESTree `Block` clones. 0.4.3 (PR #31) flipped that default to keep them in the body with semantic types — load-bearing for zmod (we rely on `root.find("GlimmerCommentStatement")` and `root.find("GlimmerMustacheCommentStatement")` walking visitor keys) but broken for ESLint consumers (directive scanner, indent rule, Block-filter rules). Upstream ember-estree is moving back to the 0.4.2 default and gating body-retention behind an opt-in flag so both contracts can coexist cleanly. Set `keepCommentsInBody: true` in the parse adapter to preserve zmod's comment-traversal behavior. No user-visible changes — all 106 tests continue to pass, including the 24-case `tests/glimmer-comments.test.ts` suite. Depends on ember-estree proposal/option-b-opt-in-keep-comments-in-body. --- src/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e62bdc5..e71965b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,7 +40,18 @@ import type { Parser, ParseOptions } from "zmod"; */ export const emberParser: Parser = { parse(source: string, options?: ParseOptions): any { - const ast = toTree(source, { ...(options as any), includeParentLinks: false }); + const ast = toTree(source, { + ...(options as any), + includeParentLinks: false, + // zmod walks the tree via visitor keys; keep Glimmer comment nodes + // in GlimmerTemplate.body (with semantic types + longForm) so + // `root.find("GlimmerCommentStatement")` / `root.find("GlimmerMustacheCommentStatement")` + // can reach them. Without this opt-in, ember-estree's default + // removes them from body and surfaces only Block-typed clones + // in `ast.comments` — the right contract for ESLint consumers, + // but invisible to zmod's tree-walker. + keepCommentsInBody: true, + }); return ast; },