Skip to content

feat: skip Ember 7.1 built-in template keywords in scope registration#211

Merged
NullVoxPopuli merged 2 commits into
ember-tooling:mainfrom
aklkv:feat/ember-7.1-builtin-keywords
May 15, 2026
Merged

feat: skip Ember 7.1 built-in template keywords in scope registration#211
NullVoxPopuli merged 2 commits into
ember-tooling:mainfrom
aklkv:feat/ember-7.1-builtin-keywords

Conversation

@aklkv
Copy link
Copy Markdown
Contributor

@aklkv aklkv commented May 15, 2026

ember-source 7.1 ships 14 built-in template keywords (and, array, element, eq, fn, gt, gte, hash, lt, lte, neq, not, on, or) that can be referenced in strict-mode templates without an explicit import. @glimmer/syntax's isKeyword table predates these, so registerPathExpression was lifting them into JS scope and ESLint's no-undef would flag bare references like {{eq}} or {{on "click" handler}}.

Add a small helper that gates on the consumer's resolved ember-source version (>=7.1) and bails out of scope registration for the 14 names. Pre-7.1 projects keep their existing behaviour, so typos still surface as no-undef. The version probe is wrapped in try/catch and cached, so per-identifier cost is a Set lookup.

ember-source 7.1 ships 14 built-in template keywords (and, array, element, eq, fn, gt, gte, hash, lt, lte, neq, not, on, or) that can be referenced in strict-mode templates without an explicit import. @glimmer/syntax's isKeyword table predates these, so registerPathExpression was lifting them into JS scope and ESLint's no-undef would flag bare references like {{eq}} or {{on "click" handler}}.

Add a small helper that gates on the consumer's resolved ember-source version (>=7.1) and bails out of scope registration for the 14 names. Pre-7.1 projects keep their existing behaviour, so typos still surface as no-undef. The version probe is wrapped in try/catch and cached, so per-identifier cost is a Set lookup.
Per upstream review: when a user explicitly imports a 7.1 built-in (e.g. `import { eq } from 'ember-truth-helpers'`) or otherwise binds the name in JS scope, the import must still be marked as used. Previously the bail-out fired before `findVarInParentScopes`, so `no-unused-vars` would flag the import.

Move the keyword bail-out below the scope lookup and only skip registration when there is no local binding. Add a test-only `_setEmberSourceVersionForTesting` helper plus end-to-end Linter coverage for: bare 7.1 keyword on >=7.1 (no no-undef), imported 7.1 keyword (no no-unused-vars + no no-undef), unrelated free identifier (still no-undef), bare 7.1 keyword on <7.1 (still no-undef), and bare 7.1 keyword when ember-source is unresolvable (still no-undef).
@NullVoxPopuli NullVoxPopuli added the enhancement New feature or request label May 15, 2026
@NullVoxPopuli NullVoxPopuli merged commit e8cf4fc into ember-tooling:main May 15, 2026
34 checks passed
@aklkv aklkv deleted the feat/ember-7.1-builtin-keywords branch May 15, 2026 20:54
@github-actions github-actions Bot mentioned this pull request May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants