Skip to content

Extract rule: template-no-valueless-arguments#2591

Merged
NullVoxPopuli merged 2 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-valueless-arguments
Mar 21, 2026
Merged

Extract rule: template-no-valueless-arguments#2591
NullVoxPopuli merged 2 commits intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-no-valueless-arguments

Conversation

@NullVoxPopuli
Copy link
Contributor

Split from #2371.

Copy link

@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-valueless-arguments

Compared against the original ember-template-lint rule no-valueless-arguments.

What's done well

  • Clean, minimal implementation. The rule is simple and the port keeps it that way -- just 35 lines of rule code.
  • Correct detection approach. Checking for @ prefix on the attribute name and then verifying no = in the source text is a pragmatic workaround since the ESLint Glimmer AST may not expose an isValueless property directly.
  • All original test cases are ported -- both good and bad cases match the original exactly.
  • Both gjs and hbs parser modes are tested.

Observations and potential issues

  1. Detection mechanism differs from the original. The original rule relies on node.isValueless -- a boolean property provided by the Handlebars AST. The new rule checks !text.includes('=') on the source text. This is a reasonable heuristic but could theoretically produce false positives if an attribute name itself contains = (extremely unlikely for @-prefixed names) or false negatives in edge cases where the AST representation differs from source. In practice this should be fine, but it's worth noting the approach is source-text-based rather than AST-property-based.

  2. context.sourceCode || context.getSourceCode() -- the fallback to getSourceCode() is good for backwards compatibility with older ESLint versions. However, getSourceCode() is deprecated in ESLint 9+. Since this plugin likely targets a range of ESLint versions, the || pattern is appropriate.

  3. No fixable property in meta. The original also doesn't provide autofix, so this is consistent.

  4. The error message matches exactly: "Named arguments should have an explicitly assigned value." -- identical to the original.

  5. Missing a Foo @bar={{true}} gjs valid test. Wait, actually it is there. The test coverage looks complete.

Summary

Straightforward, clean port. The source-text heuristic for valueless detection is the only notable divergence from the original's approach, and it works correctly for all test cases. This is a simple rule and the migration handles it well.


Automated review comparing with ember-template-lint source

@NullVoxPopuli NullVoxPopuli force-pushed the nvp/template-lint-extract-rule-template-no-valueless-arguments branch from 838cda0 to 9b5f84a Compare March 21, 2026 00:40
@NullVoxPopuli NullVoxPopuli merged commit 506418a into ember-cli:master Mar 21, 2026
9 checks passed
@NullVoxPopuli NullVoxPopuli deleted the nvp/template-lint-extract-rule-template-no-valueless-arguments branch March 21, 2026 00:48
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