eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

Make attributes "buckets" configurable

Open markusheiden opened this issue 1 year ago • 3 comments

What rule do you want to change? vue/attributes-order

Does this change cause the rule to produce more or fewer warnings? The same as before.

How will the change be implemented? (New option, new default behavior, etc.)? More flexible configuration, e.g. by adding options.

Please provide some example code that this change will affect: Quasar uses row-key in q-table that is IMO similar to key used for v-for. Currently, I cannot order these to the same position, see examples below.

What does the rule currently do for this code?

q-table(v-model="row", row-key="id")

What will the rule do after it's changed? By adding row-key to UNIQUE, it would allow:

q-table(row-key="id", v-model="row")

markusheiden avatar Jul 22 '24 14:07 markusheiden

Instead of "UNIQUE", you can specify the attributes directly, and you can use an array to allow them to be in any order internally, so e.g. replace "UNIQUE" with ["id", "row-key"] in your rule configuration.

FloEdelmann avatar Jul 22 '24 15:07 FloEdelmann

I would like a possibility to just add some attributes without the need to redefine all existing ones nor the order of the buckets. But I will try the suggested solution.

Just to be sure, because that's not in the docs: I have to configure the order by using an array of attributes in place of UNIQUE? The docs just mention that possibility for using arrays of bucket names.

markusheiden avatar Jul 22 '24 15:07 markusheiden

That did not work:

'vue/attributes-order': [
  'error',
  {
    order: [
      'DEFINITION',
      'LIST_RENDERING',
      'CONDITIONALS',
      'RENDER_MODIFIERS',
      'GLOBAL',
      /* UNIQUE: */ ['ref', 'key', /* added: */ 'row-key'],
      'TWO_WAY_BINDING',
      'OTHER_DIRECTIVES',
      'OTHER_ATTR',
      'EVENTS',
      'CONTENT'
    ],
    alphabetical: false
  }
]
Error: .eslintrc.cjs:
        Configuration for rule "vue/attributes-order" is invalid:
        Value ["ref","key","row-key"] should be equal to one of the allowed values.
        Value "ref" should be equal to one of the allowed values.
        Value ["ref","key","row-key"] should match some schema in anyOf.

markusheiden avatar Jul 22 '24 15:07 markusheiden