sveltejs / prettier-plugin-svelte

Format your svelte components using prettier.
MIT License
715 stars 95 forks source link

Error with inline functions and pug templates #366

Open mfinelli opened 1 year ago

mfinelli commented 1 year ago

Hi, I have the following output from running prettier and it tells me to open an issue, here's how to reproduce:

package.json:

{
  "name": "prettier-bug",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@prettier/plugin-pug": "^2.5.0",
    "prettier": "^2.8.8",
    "prettier-plugin-svelte": "^2.10.0"
  }
}

Test.svelte:

<script>
        const someFunction = (someArg) => {
                console.log("something")
        };
</script>

<template lang="pug">
        button(on:click="{(e) => someFunction(e)}")
                | A button
</template>

Running npx prettier Test.svelte produces the following message:

Test.svelteThe following expression could not be formatted correctly. Please try to fix it yourself and if there is a problem, please open a bug issue: (e) => someFunction(e)