Skip to content

Extract rule: template-no-unknown-arguments-for-builtin-components#2583

Merged
NullVoxPopuli merged 5 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-unknown-arguments-for-builtin-components
Mar 22, 2026
Merged

Extract rule: template-no-unknown-arguments-for-builtin-components#2583
NullVoxPopuli merged 5 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-unknown-arguments-for-builtin-components

Conversation

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

Split from #2371.

Copy link
Copy Markdown

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: template-no-unknown-arguments-for-builtin-components (comparing with ember-template-lint no-unknown-arguments-for-builtin-components)

Coverage

This is the most complex rule in this batch. The migration covers the core detection logic well.

What's done well

  • Complete KnownArguments data: The argument maps for LinkTo, Input, and Textarea are identical to the original -- all deprecated arguments, deprecated events, conflicts, and required argument lists are faithfully reproduced.
  • Error message functions (deprecateArgument, deprecateEvent) produce the same messages as the original.
  • Conflict detection is correctly implemented.
  • Comprehensive tests: Both gjs and hbs modes tested with a good variety of cases (typos, deprecated args, deprecated events, conflicts, unknown args).
  • templateMode: 'both' is appropriate since <Input>, <Textarea>, and <LinkTo> exist in both modes.

Items needing attention

  1. Fuzzy matching differs from original: The original uses fuse.js for fuzzy matching, while this PR implements a custom fuzzyMatch function. This means suggestion quality may differ. For example, in the HBS test, @random suggests @dragEnd -- the original with Fuse.js may produce a different suggestion. This is a pragmatic tradeoff (avoiding a new dependency), but worth documenting.

  2. Missing required argument validation: The original rule checks nodeMeta.required and reports when none of the required argument variants are present (e.g., LinkTo requires at least one of @route, @query, @model, or @models). The required data is present in KnownArguments but the create() function does not check it. This means cases like <LinkTo /> (with no route-related arguments) will not produce an error. The original has a REQUIRED_MESSAGE function and corresponding logic.

  3. Missing fixability: The original rule supports auto-fixing deprecated arguments (converting @elementId to id, converting deprecated events to {{on}} modifiers). The ESLint version has fixable: null, so no auto-fix is provided. This is understandable given the complexity of AST manipulation in the ESLint context, but worth noting as a feature gap.

  4. Conflict message wording difference: The original uses "only one should exists" (with typo). The PR uses "only one should exist." (corrected). This is actually an improvement, but test assertions should match.

Verdict

Good migration overall, especially given the complexity. The missing required argument check is the most significant gap -- it means <LinkTo /> without any route/query/model args won't be flagged. Consider adding that check or documenting it as a known limitation.


🤖 Automated review comparing with ember-template-lint source

NullVoxPopuli and others added 3 commits March 21, 2026 20:49
…mports

In gjs/gts files, when a developer imports a custom component with a name
that matches an Ember built-in (Input, Textarea, LinkTo), the rule would
incorrectly flag unknown arguments. This checks scope analysis to determine
if the tag name resolves to a JS-scope variable with a definition (e.g. an
import binding), and skips validation in that case.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The rule already had logic to check that required arguments are present
(e.g., LinkTo requires at least one of @route, @query, @model, or @models),
but this code path had no test coverage. Add test cases for both GJS and HBS
parsers to verify that <LinkTo /> without any required argument correctly
reports a requiredArgument error.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@NullVoxPopuli NullVoxPopuli force-pushed the nvp/template-lint-extract-rule-template-no-unknown-arguments-for-builtin-components branch from bd3f119 to 40bdae0 Compare March 22, 2026 00:49
@NullVoxPopuli NullVoxPopuli enabled auto-merge March 22, 2026 01:09
@NullVoxPopuli NullVoxPopuli merged commit 9ba83ed into ember-cli:master Mar 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants