Skip to content

Allow thening in await without introducing a variable #15981

@VsevolodGolovanov

Description

@VsevolodGolovanov

Describe the problem

There is an "Update" button that reloads some data. It can be disabled.

{#snippet updateButton(updating: boolean)}
	<button type="button" disabled={updating} onclick={/* update */}>
		Update
	</button>
{/snippet}

When the data is being updated the button is disabled until the update finishes:

{#await updateableData}
	{@render updateButton(true)}
{:then loadedData}
	{@render updateButton(false)}
{/await}

The button doesn't really care about loadedData and doesn't use it - it only cares about updateableData resolvness.
The problem is, the linter is gonna mark the unused variable with a warning:
Image

At the moment I can suppress the warning and provide a telling name:

<!--eslint-disable-next-line-->
{:then dontNeedThisHere}

Describe the proposed solution

There could be a way to not introduce the variable in the first place.

One option is to allow to just do
{:then}
without a name. But maybe that's not the best idea because most of the times you'd probably be interested in the variable and the error is a useful reminder.

A better option is to allow to explicitly opt out of a variable. Like, for example, the lambdas do it:
{:then ()}
Or:
{:then {}}
, but that results in ESLint: Unexpected empty object pattern currently.

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions