Eslint-plugin-vue: slot-scope support multiple parameters

Created on 12 Dec 2018  Â·  12Comments  Â·  Source: vuejs/eslint-plugin-vue

Please describe what the rule should do:

It is understandable to pass only one parameter in the template.
But for some of the underlying general-purpose components written in render, it is possible to pass multiple parameters.
For example,
Edit Vue Antd Template

<span slot="action" slot-scope="text, record">
...
</span>

The slot-scope is like a function. For example ()=> .
I expect to get a slot that can be reused. Its role is to provide a component with a reusable slot.
So should not be limited by the number of parameters.
Maybe support only one parameter is the best practice.
But should not be so strictly prohibited.
It is best to provide a separate rule instead of no-parsing-error.

What category should the rule belong to?

  • [ ] Enforces code style
  • [ ] Warns about a potential error
  • [X] Suggests an alternate way of doing something
  • [ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:


Additional context

bug enhancement

All 12 comments

It seems that you can use multiple arguments when the user writes the following in render.

this.$scopedSlots.default(a, b, c)

If we support multiple arguments, I think that vue-eslint-parser needs the following changes.

  • Change to not throw parse errors.
  • Change AST of VSlotScopeExpression.
interface VSlotScopeExpression <: Expression {
    type: "VSlotScopeExpression"
-    id: Pattern
+    params: [ Pattern ];
}

@mysticatea
What do you think?

You are right. I use it like this.
this.$scopedSlots.xxx(a, b, c)

So I think that empty values should also be allowed (#670).
Even if I pass the value, I don't necessarily need to use it.
If I don't use it, it will report an unused warning(vue/no-unused-vars).

So I think that empty values should also be allowed (#670).
Even if I pass the value, I don't necessarily need to use it.

True, I think that empty should be allowed as you say. I close PR #670.

Is there a plan to support multiple parameters?

I apologize for my delay.

At that time, I confirmed that Vue.js source code (src/core/instance/render-helpers/render-slot.js) and I believed that the slot-scope should have only one parameter. I had forgotten JSX.

@ota-meshi Your proposal looks good to me.

Still have problems.
version info:

"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.1.0",
"vue-eslint-parser": "^5.0.0",

image

@michalsnik any info about when we can see #754 in npm? Thanks

Probably in the next day @OlegGavrilov :)

Probably in the next day @OlegGavrilov :)

@michalsnik is it still 5.1.0 (a month old) in NPM? Sorry if I'm missing something.

@OlegGavrilov So the improbable happened: it hasn't been released yet. Just be patient.

"eslint-plugin-vue": "^5.2.2" still have this problem.

More unfortunately, I can't close this rule.
PS:The previous version can be closed.

Thank you, it has been solved.
But Vetur still has some problems, I will open an issue under Vetur.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hyzual picture Hyzual  Â·  3Comments

deangoku picture deangoku  Â·  4Comments

nirazul picture nirazul  Â·  3Comments

rodrigoabb picture rodrigoabb  Â·  3Comments

rodneyrehm picture rodneyrehm  Â·  4Comments