Skip to content

feat: lint against using <Request><:content> without consuming the actual request result #10058

@runspired

Description

@runspired

Why?

Often this indicates an anti-pattern in which the result is being indirectly consumed by accessing the resource in the store via other means.

What?

This will need to be linted against using an ember-template-lint plugin. We currently don't have an ember-template-lint-plugin-warp-drive package, so you'll need to create one. I will provide instructions for how to do so below.

Resources

Instructions

  1. Create a new package at packages/ember-template-lint-plugin-warp-drive
    • Follow existing patterns for new packages (e.g. can follow patterns from packages/eslint-plugin-warp-drive)
    • Prefer TypeScript over JavaScript
    • Use pnpm for package management
  2. Write tests for a new rule: always-use-request-content.
    Tests should include, but not necessarily be limited to:
    • Good examples
      • You can extract good examples from <Request> component docs: https://github.com/emberjs/data/tree/main/warp-drive-packages/ember#request-
      • <Request> with no content block--as long as it uses the other blocks (<Request @request={{@request}}><:idle></:idle><:loading></:loading>...</Request>)
      • Note: It's fine for users to name the variable yielded by the content block whatever they want
      • Note: The content block yields a second "state" argument that may or may not be used; this is unrelated to this lint rule but we should test that it's allowed
    • Bad examples:
      • <Request> with no content block and not other blocks (<Request @request={{@request}}>...</Request>)
      • <Request> with content block but no yielded result (<Request @request={{@request}}><:content>...</:content></Request>)
      • <Request> with content block and yielded result, but the result isn't used (<Request @request={{@request}}><:content as |result|>...result not used...</:content></Request>)
  3. Create a new rule always-use-request-content that passes the tests.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions