Skip to content

Rule proposal: slot-syntax rule #800

Closed
@ota-meshi

Description

@ota-meshi

Please describe what the rule should do:

This rule reports deprecated or removed (in Vue.js 2.6.0) slot syntax.

This rule has the following options.

{
  "vue/slot-syntax": ["error", {
    "v-slot": true,
    "slot": true,
    "slot-scope": true,
    "scope": false
  }]
}
  • v-slot ... If false, disallow v-slot. default true
  • slot ... If false, disallow slot. default true
  • slot-scope ... If false, disallow slot-scope. default true
  • scope ... If false, disallow scope. default false

I think we need to discuss the default options.
The listed defaults are designed not to warn v2.5 - 2.6 users.

What category should the rule belong to?

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

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

<template>
  <ListComponent>
    <!-- ✓ GOOD -->
    <template v-slot:name="props">
      {{ props.title }}
    </template>
    <template slot="name" slot-scope="props">
      {{ props.title }}
    </template>
  </ListComponent>
  <ListComponent>
    <!-- ✗ BAD -->
    <template slot="name" scope="props">
      {{ props.title }}
    </template>
  </ListComponent>
</template>
  • option {"v-slot": true, "slot": false, "slot-scope": false, "scope": false}

You are using Vue.js v2.6.0+ and you want to use only v-slot

<template>
  <ListComponent>
    <!-- ✓ GOOD -->
    <template v-slot:name="props">
      {{ props.title }}
    </template>
  </ListComponent>
  <ListComponent>
    <!-- ✗ BAD -->
    <template slot="name" slot-scope="props">
      {{ props.title }}
    </template>
    <template slot="name" scope="props">
      {{ props.title }}
    </template>
  </ListComponent>
</template>
  • option {"v-slot": false, "slot": true, "slot-scope": true, "scope": false}

You are using Vue.js v2.5.x

<template>
  <ListComponent>
    <!-- ✓ GOOD -->
    <template slot="name" slot-scope="props">
      {{ props.title }}
    </template>
  </ListComponent>
  <ListComponent>
    <!-- ✗ BAD -->
    <template v-slot:name="props">
      {{ props.title }}
    </template>
    <template slot="name" scope="props">
      {{ props.title }}
    </template>
  </ListComponent>
</template>

Additional context

v-slot
slot
slot-scope
scope


I started implementing on this branch.
However, we need to make the parser supports to v-slot.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions