-
-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Motivation
Attributes on Svelte components and html can get unwieldy and hard to parse if there are too many. This is especially true when there is a lot of directives involved. One of the main thing I appreciate in eslint-plugin-react is their jsx-sort-props
rule. It makes even complex components easy to read.
Proposed solution
Add sort-attributes rule to enforce a sort order of attributes. Alphabetical order would probably suffice for most cases however some sort of predefined "natural" order would be best. Here I'm thinking of the in:
and out:
directive. I think most would keep this two attributes logically together. jsx-sort-props
has accumulated a fair amount of these, e.g.: on:
event listeners last for Svelte.
A simple alphabetical ordering I usually maintain manually.
<Checkbox
bind:this={checkbox}
class="text-md"
class:blue={isSelected}
{completed}
{id}
in:fly
on:change={handleChange}
out:fade
use:action
{...$$props}/>
Appreciate any thought on this!