Post-merge-review: Fix template-no-inline-linkto false positive in GJS/GTS#2679
Open
johanrd wants to merge 2 commits intoember-cli:masterfrom
Open
Post-merge-review: Fix template-no-inline-linkto false positive in GJS/GTS#2679johanrd wants to merge 2 commits intoember-cli:masterfrom
template-no-inline-linkto false positive in GJS/GTS#2679johanrd wants to merge 2 commits intoember-cli:masterfrom
Conversation
The angle-bracket visitor checks `node.tag === 'LinkTo'` by bare name, which causes two GJS/GTS bugs (the same class as PR ember-cli#2652 fixed for template-no-link-to-tagname): - A user-authored `<LinkTo>` from any non-`@ember/routing` source is falsely flagged when childless. - A renamed framework import (`import { LinkTo as Link } from '@ember/routing'`) used as `<Link />` is missed entirely. Adopt the same `@ember/routing` import-tracker pattern: in strict mode, only flag elements whose tag is in the tracked map (covers renamed imports). HBS path uses bare-name match (no imports possible). Curly `{{link-to ...}}` handler is gated to HBS only — `link-to` is not a valid JS identifier, so it cannot be a user binding in strict mode, and the strict-mode compiler would already reject the source. Tests: 21 (was 14) — adds 4 new valid GJS/GTS cases (no-import bare `<LinkTo>` in .gjs and .gts, with-import block-form `<LinkTo>...</LinkTo>`, with-renamed-import block-form `<Link>...</Link>`) and 3 new invalid cases (with-import childless `<LinkTo />` in .gjs and .gts, renamed childless `<Link />`). Docs updated to document the strict-mode behavior.
…mitation - importedLinkComponents: Map<string, true> → Set<string> - Move const sourceCode inside the curly-fixer (only user) - Comment: namespace imports (import * as routing from '@ember/routing') are not tracked; dotted tag paths are not a realistic usage pattern.
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
masterThe angle-bracket visitor checks
node.tag === 'LinkTo'by bare name. In GJS/GTS this produces two false signals:A user-authored
<LinkTo>from any non-@ember/routingsource is falsely flagged when childless:A renamed framework import is missed entirely:
Fix
Track
ImportDeclarationfrom@ember/routingforLinkTo(including renamed imports) in.gjs/.gts. Only flag elements whose tag is in the tracked set. The curly{{link-to ...}}handler is now gated to HBS only —link-tois not a valid JS identifier, so it cannot be a user binding in strict mode, and the strict-mode compiler would already reject the source. Skipping the autofix in strict mode avoids producing also-broken{{#link-to ...}}.Note on related rules
The same bug class (bare-name
LinkTo/link-tomatch with no awareness of@ember/routingimports) also exists intemplate-no-link-to-tagname,template-no-invalid-link-text, andtemplate-no-invalid-link-titleonmaster. Those should be fixed in follow-up PRs using the same pattern.Limitations
Namespace imports (
import * as routing from '@ember/routing'; <routing.LinkTo />) are not tracked — dotted tag paths would need a separate match and are not a realistic usage pattern for this component. Documented in a code comment.Test plan
21 tests pass on the branch (was 14). New cases:
.gjsand.gts) — user component, not flagged@ember/routingimport — block-form<LinkTo>...</LinkTo>and renamed<Link>...</Link>not flagged (have children)<LinkTo />flagged<Link />flaggedHBS path is unchanged. Lint and prettier pass.