Post-merge-review: Fix template-no-unbound false positive in GJS/GTS#2668
Open
johanrd wants to merge 1 commit intoember-cli:masterfrom
Open
Post-merge-review: Fix template-no-unbound false positive in GJS/GTS#2668johanrd wants to merge 1 commit intoember-cli:masterfrom
template-no-unbound false positive in GJS/GTS#2668johanrd wants to merge 1 commit intoember-cli:masterfrom
Conversation
7f08d51 to
e5b3dfc
Compare
2a9f19b to
7da211d
Compare
`unbound` is an ambient strict-mode keyword in Glimmer/Ember (registered
in STRICT_MODE_KEYWORDS, backed by BUILTIN_KEYWORD_HELPERS.unbound), so
`{{unbound foo}}` works in .gjs/.gts without an import. The rule should
still flag those uses everywhere — but skip when `unbound` resolves to
a JS binding or template block param.
ember-eslint-parser registers template block params in scope, so a
single sourceCode.getScope walk covers both JS bindings and block
params. Also updates templateMode from 'loose' to 'both' so the rule
runs in strict mode.
7da211d to
597f0d5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken on
masterFlags
{{unbound}}as the classic Ember resolver-resolved helper, but doesn't account for JS-scope shadowing in GJS/GTS strict mode. A user-importedunbound(import unbound from './my-unbound-helper') or a block-paramunbound({{#let (...) as |unbound|}}) is incorrectly flagged.Why a JS-scope check (not an
.hbs-only gate)unboundis an ambient strict-mode keyword in Glimmer/Ember — registered inSTRICT_MODE_KEYWORDSand backed byBUILTIN_KEYWORD_HELPERS.unbound. So<template>{{unbound foo}}</template>works in.gjs/.gtswithout an import. Gating the rule to.hbswould hide the very thing the rule exists to flag (false negative).Fix
Mirror the
template-no-logpattern: walksourceCode.getScope().variablesto detect JS bindings, plus track template block params, and skip reporting only when the identifier resolves to a local. UpdatetemplateModefrom'loose'to'both'to reflect that the rule now runs in strict mode.Test plan
13/13 tests pass on the branch.
{{unbound foo}}in.gjsis now correctly flagged again (would have been a false negative under an.hbs-only gate).import unbound from '...'; {{unbound foo}}in.gjs/.gtsis correctly skipped (JS-scope binding).{{#let (...) as |unbound|}}{{unbound}}{{/let}}is correctly skipped (block-param shadowing).