# svelte/first-attribute-linebreak

enforce the location of first attribute

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

# 📖 Rule Details

This rule aims to enforce a consistent location for the first attribute.

<script>
  /* eslint svelte/first-attribute-linebreak: "error" */
</script>

<!-- ✓ GOOD -->
<input type="checkbox" />
<button
  type="button"
  on:click={click} />
<button type="button" on:click={click} />

<!-- ✗ BAD -->
<input
  
Expected no linebreak before this attribute. (svelte/first-attribute-linebreak)
type="checkbox"
/>
<button
Expected a linebreak before this attribute. (svelte/first-attribute-linebreak)
type="button"
on:click={click} /> <button
Expected no linebreak before this attribute. (svelte/first-attribute-linebreak)
type="button"
on:click={click} />

# 🔧 Options

{
  "svelte/first-attribute-linebreak": [
    "error",
    {
      "multiline": "below", // or "beside"
      "singleline": "beside" // "below"
    }
  ]
}
  • multiline … The location of the first attribute when the attributes span multiple lines. Default is "below".
    • "below" … Requires a newline before the first attribute.
    • "beside" … Disallows a newline before the first attribute.
  • singleline … The location of the first attribute when the attributes on single line. Default is "beside".
    • "below" … Requires a newline before the first attribute.
    • "beside" … Disallows a newline before the first attribute.

# 🚀 Version

This rule was introduced in eslint-plugin-svelte v0.6.0

# 🔍 Implementation