ITADN

vue/attributes-order: add option to ignore v-bind="object" (attribute spread) from ordering/fixing

#2999Openivanmem 创建于 2026-01-12
I
ivanmemcommented
Hi! We use `vue/attributes-order` with a custom `order`. We want to keep attribute spread (`v-bind="attrs"`) after event listeners for readability, but the rule always reports and auto-fixes it to be placed before events. This is especially painful because `v-bind="object"` is often used as a “rest props” pass-through and developers may want it at the end (or at least not enforced by the ordering rule). **Repro (Vue 3):** ```vue <template> <MyButton @click="onClick" v-bind="attrs" /> </template> ``` **Config:** ```js { rules: { 'vue/attributes-order': ['warn', { order: [ 'DEFINITION', ['CONDITIONALS', 'LIST_RENDERING'], 'SLOT', 'ATTR_STATIC', 'ATTR_SHORTHAND_BOOL', 'ATTR_DYNAMIC', 'TWO_WAY_BINDING', 'OTHER_DIRECTIVES', 'RENDER_MODIFIERS', 'CONTENT', 'EVENTS', ], }], }, } ``` **Actual behavior:** `vue/attributes-order` reports and auto-fixes by moving `v-bind="attrs"` before `@click`. **Expected behavior:** Provide a way to exclude `v-bind="object"` from ordering enforcement (and fixing), e.g.: ```js 'vue/attributes-order': ['warn', { order: [/* ... */], ignore: ['v-bind'], // ignore only v-bind="object" }] ``` **Proposed semantics (minimal):** - `ignore: ['v-bind']` ignores only `v-bind="object"` (directive `bind` with no argument). - `v-bind:foo="bar"` and other directives are unaffected. **Why not `eslint-disable-next-line`:** We can workaround with `// eslint-disable-next-line vue/attributes-order` but it’s noisy and not scalable.
0 条评论