Skip to content

Mustache expressions should be wrapped in template literals for consistency with typescript eslint rules #558

Closed as not planned
@AlbertMarashi

Description

@AlbertMarashi

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I'm using eslint-plugin-svelte. (*.svelte file linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.)
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-svelte repo and open the issue in eslint-plugin-svelte repo if there is no solution.
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

0.41.0

What version of eslint-plugin-svelte and svelte-eslint-parser are you using?

What did you do?

The following is a major footgun and surface area for bugs.

<script lang="ts">

let obj = { 
  a: bool
}
</script>
<a href="/foo/{obj}">...</a>

Will result in

<a href="/foo/[object Object]">..</a>

Even in situations such as

Hello { obj }

We get

Hello [object Object]

There's exactly zero times that I've desired this behavior & almost always a surface area for bugs when refactoring props, types and etc.

This can quite easily occur throughout projects during refactoring or even just developer oversight. We should prevent this from occurring.

I view this as a quite serious typing issue, with no easy apparent remedies.

What did you expect to happen?

What actually happened?

<script lang="ts">
    const array = [1, 2, 3]
</script>
{#each array as e}
    {e}
{/each}

Gets turned into:

              
    const array = [1, 2, 3]
;function $_render1(){        
                  
Array.from(array).forEach((e) => {
    (ee);
});
}

When it should be

    const array = [1, 2, 3]
;function $_render1(){        
                  
Array.from(array).forEach((e) => {
    (`${ee}`);
});
}

Link to GitHub Repo with Minimal Reproducible Example

NA

Additional comments

No response

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