Skip to content

Add svelte/attributes-line-break #762

Open
@jamesst20

Description

@jamesst20

Motivation

There are currently 2 existing rules that helps formatting attributes line break:

  • "svelte/first-attribute-linebreak"
  • "svelte/max-attributes-per-line"

The problem with them is that there is no way to consider the line length to enforce proper style.

Description

"svelte/attributes-line-break": ["error", { printWidth: 90 }]

Examples

<script>
</script>

<!-- ✓ GOOD -->

<!-- 41 characters -->
<MyComponent attr1="test" attr2="test" />

<!-- 99 characters -->
<MyComponent
  attr1="test"
  attr2="test"
  attr3="some very long text that takes spaces and many..."
/>

<!-- ✗ BAD -->

<!-- 41 characters -->
<MyComponent
  attr1="test"
  attr2="test"
/>

<!-- 99 characters -->
<MyComponent  attr1="test"  attr2="test"  attr3="some very long text that takes spaces and many..."/>

Additional comments

These are only examples, I am not very much opiniated on the rule name or customization as long as it can give the proper result in the end.

Right now Prettier is able to enforce this style correctly, however Prettier is very opiniated and doesn't offer much customization and i would like to get rid of it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions