Closed
Description
Motivation
This rule is essentially the same as Anthony's recently published antfu/consistent-list-newline
rule, but for element attributes in Svelte files. The purpose of it is to save spending time messing with whitespace. However I write the first attribute, the rest will automatically follow the pattern.
Description
Keep attributes on same line or each on their own line based on the first attributes position
Examples
<script>
</script>
<!-- ✓ GOOD -->
<div baz foo bar="2">Text</div>
<div
baz
foo
bar="2">Text</div>
<div
foo
use:baz={{
setting: 'value',
}} />
<!-- ✗ BAD -->
<div baz
foo
bar="2">Text</div>
<div baz foo
bar="2">Text</div>
<div
baz foo bar="2">Text</div>
<div foo
bar />
<div foo use:baz={{
setting: 'value',
}} />
<div foo use:baz={{
setting: 'value',
}} use:box />
From the rule tests at https://github.com/jacob-8/eslint-plugin-svelte-stylistic/blob/main/src/rules/consistent-attribute-lines.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 2 of 2, see the first at #590)