sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
306 stars 38 forks source link

feat: add `svelte/restrict-mustache-expressions` rule #840

Closed AlbertMarashi closed 1 month ago

AlbertMarashi commented 3 months ago

Being able to use non-stringifiable objects in string contexts is a major footgun and surface area for bugs. This new rule creates lint errors for situation such as:

<script lang="ts">

let foo = {
  bar: true
}
</script>
<a href="/foo/{foo}">foo</a>

where the href is serialised into "/foo/[object Object]" which is almost never wanted behavior, and these types of bugs can easily be introduced through refactoring

Related: https://github.com/sveltejs/eslint-plugin-svelte/issues/747

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: e1c168dff0c0068d91ca138a6ddd92147b419468

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------------- | ----- | | eslint-plugin-svelte | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR