Skip to content

vue/attributes-order allow to differentiate between static and dynamic attributes #1728

Closed
@drik98

Description

@drik98

What rule do you want to change?

vue/attributes-order

Does this change cause the rule to produce more or fewer warnings?

More depending on the config. If the config does not change it should be equal.

How will the change be implemented? (New option, new default behavior, etc.)?

New option.
Currently only OTHER_ATTR can be used for attributes, no matter if they are static or dynamic (using v-bind). I'd like to differentiate between those two types. We like to have our static attributes first and our dynamic attributes second. I'd imagine you could give the option to use something like OTHER_ATTR_STATIC and OTHER_ATTR_DYNAMIC where as OTHER_ATTR would become an alias for [ 'OTHER_ATTR_STATIC', 'OTHER_ATTR_DYNAMIC' ] so current configs do not break.

Please provide some example code that this change will affect:

  <div
    prop-one="prop"
    :prop-two="prop"
    prop-three="prop">

What does the rule currently do for this code?

  <div
    prop-one="prop"
    :prop-two="prop"
    prop-three="prop">

What will the rule do after it's changed?

using the config

{
  "vue/attributes-order": ["error", {
    "order": [
      "DEFINITION",
      "LIST_RENDERING",
      "CONDITIONALS",
      "RENDER_MODIFIERS",
      "GLOBAL",
      ["UNIQUE", "SLOT"],
      "TWO_WAY_BINDING",
      "OTHER_DIRECTIVES",
      "OTHER_ATTR_STATIC",
      "OTHER_ATTR_DYNAMIC",
      "EVENTS",
      "CONTENT"
    ],
    "alphabetical": false
  }]
}

it should change to

  <div
    prop-one="prop"
    prop-three="prop"
    :prop-two="prop">

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