question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

attributes-order doesn't specify where slot-scope goes.

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.18.2
  • eslint-plugin-vue Version: 4.3.0
  • Node Version: 8.9.4

Please show your full configuration: N/A

What did you do? Please include the actual source code causing the issue. I have a template that uses a component supporting scoped slots, but the rule vue/attributes-order does not specify where the slot-scope attribute should go and treats it like a normal attribute in terms of order.

Before I updated to the version including this rule, I’d always written them first, like below:

<template>
   <component-with-scoped-slots>
      <div slot="left" slot-scope="{ someVar }" :class="leftSlotClasses">...</div>
      <div slot="right" slot-scope="{ someVar }" :class="rightSlotClasses">...</div>
   </component-with-scoped-slots>
</template>

What did you expect to happen? I expected the position of slot and slot-scope to be the same in this rule.

What actually happened? Please include the actual, raw output from ESLint. Since slot-scope is not explicitly covered, it is treated like any other custom attr, and expected to be after any bound ones. [eslint] Attribute ":class" should go before "slot-scope". (vue/attributes-order)

~I can make them read at the expected positions thusly:~

   <div slot="left" :slot-scope="'{ someVar }'" :class="leftSlotClasses">...</div>

~but that feels like cheating…~

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
GufNZcommented, Mar 22, 2018

@michalsnik The PR fixes just that, and I was going to make sure the tests cover the new change, but they don’t yet cover [slot] anyway, so it could go in as is I guess. All the change does is add [slot-scope] to the same category as [slot], namely UNIQUE.

0reactions
michalsnikcommented, Mar 22, 2018

Thanks for posting this issue and working on it @GufNZ! Let me know once it’s ready so I can review 😃 Let’s leave <slot> case for now and focus on treating slot-scope as equal in terms of order to slot attribute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Evaluation of slot content's context is inconsistent ...
This is possible with scoped slots, but currently scoped slots can only exist if you declare something in the slot-scope attribute.
Read more >
Using Slots In Vue.js
Slots are a powerful tool for creating reusable components in Vue.js, though they aren't the simplest feature to understand.
Read more >
'v-model' directives cannot update the iteration variable itself
My solution was very simple (see v-model="tags[index]" ):. Instead of doing this: <template v-for="tag in tags"> <TagView :key="tag.key" ...
Read more >
Renderless Components in Vue.js
A renderless component is a component that doesn't render any of its own HTML. Instead it only manages state and behavior, exposing a...
Read more >
Vue 3 Migration Changes: Replace, Rename, and Remove ...
Use of v-slot instead of pairing together slot and slot-scope to do the ... Vue 3 doesn't replace the element that your app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found