Skip to content

feat: Add svelte/brackets-same-line rule #590

Closed
@jacob-8

Description

@jacob-8

Motivation

I don't like brackets on their own line as it makes the code much longer and harder to read. It may be useful for editing but it's just messy overall. Sometimes use of VSCode's built-in formatter or projects that use to use prettier can have a lot of brackets on new lines. This rule makes it easy to clean things up.

Description

Keep closing brackets on the same line as the last attribute or the tag itself

Examples

<script>
</script>

<!-- ✓ GOOD -->
<div>Text</div>

<div title="foo">Text</div>

<div 
  bar 
  title="foo">Text</div>

<div>
  Text
</div>

<div />

<!-- ✗ BAD -->
<div
  bar
  title="foo"
  >Text</div>

<div
  >Text</div>

<div
  >
  Text</div>

<div>Text</div
  >

<div
  />

From the rule tests at https://github.com/jacob-8/eslint-plugin-svelte-stylistic/blob/main/src/rules/brackets-same-line.test.ts

Additional comments

I've already published it to npm as eslint-plugin-svelte-stylistic so I'm set, but I thought others might appreciate it so wanted to propose adding it here. What do you think? (rule 1 of 2, see second at #591)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions