Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting of new getter/setter bind functions #479

Open
KieranP opened this issue Jan 11, 2025 · 0 comments
Open

Formatting of new getter/setter bind functions #479

KieranP opened this issue Jan 11, 2025 · 0 comments

Comments

@KieranP
Copy link

KieranP commented Jan 11, 2025

I have the following code after being formatted:

<input
  type="checkbox"
  bind:checked={(): boolean => settings.expandDescriptions,
  (v: boolean): void => {
    localStorage.setItem('expandDescriptions', v.toString())
    settings.expandDescriptions = v
  }}
/>

As you can see, prettier-plugin-svelte is formatting the getter onto the same line as the bind declaration (because of line length), and the setter is at the same indent level as attributes.

I recommend adjusting the formatting output to always put getter and setter on different lines, regardless of line length:

<input
  type="checkbox"
  bind:checked={
    (): boolean => settings.expandDescriptions,
    (v: boolean): void => {
      localStorage.setItem('expandDescriptions', v.toString())
      settings.expandDescriptions = v
    }
  }
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant