🔧 The --fix
option on the command line can automatically fix some of the problems reported by this rule.
Element attributes must be ordered. By default, the order is:
- arguments
- attributes
- element modifiers
Note that this ordering only applies to angle bracket invocation syntax, as mustache/curly invocation syntax only includes a single type attributes
.
This rule forbids the following (in the default ordering):
This rule allows the following:
The following values are valid configuration:
- boolean --
true
to enable /false
to disable - object -- An object with the following keys:
order
-- An array of attribute types (defaults to['arguments', 'attributes', 'modifiers']
- Note that curly component invocations will default to
['attributes']
since they don’t have other attribute types
- Note that curly component invocations will default to
alphabetize
--true
to enforce ordering attributes alphabetically (defaults totrue
)
Note that the position of ...attributes
(“splattributes”) is significant: attributes that appear before ...attributes
can be overridden by values present in ...attributes
but attributes appearing after ...attributes
will always take precedence and cannot be overridden by ...attributes
.
For this reason, nodes which contain ...attributes
surrounded by other attribute types cannot be safely reordered without causing breakages. If ...attributes
is the first or last attribute of a node however, the splattributes will be left in the same position and sorting for the rest of the attribute types will be ordered as normal.
An example with splattributes where ordering can occur automatically:
Fixed version:
A different example with splattributes where ordering can not occur automatically: