Skip to content

Commit 82616d6

Browse files
authored
Add no-deprecated-v-enter-v-leave-class rule (#53)
1 parent d6a5144 commit 82616d6

File tree

15 files changed

+3336
-904
lines changed

15 files changed

+3336
-904
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,14 @@ For example:
136136
```json
137137
{
138138
"rules": {
139-
"vue-scoped-css/require-selector-used-inside": "error"
139+
"vue-scoped-css/no-deprecated-v-enter-v-leave-class": "error"
140140
}
141141
}
142142
```
143143

144144
| Rule ID | Description | |
145145
|:--------|:------------|:---|
146+
| [vue-scoped-css/no-deprecated-v-enter-v-leave-class](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-deprecated-v-enter-v-leave-class.html) | disallow v-enter and v-leave classes. | |
146147
| [vue-scoped-css/require-selector-used-inside](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/require-selector-used-inside.html) | disallow selectors defined that is not used inside `<template>` | |
147148

148149
<!--RULES_TABLE_END-->

docs/rules/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ For example:
5555
```json
5656
{
5757
"rules": {
58-
"vue-scoped-css/require-selector-used-inside": "error"
58+
"vue-scoped-css/no-deprecated-v-enter-v-leave-class": "error"
5959
}
6060
}
6161
```
6262

6363
| Rule ID | Description | |
6464
|:--------|:------------|:---|
65+
| [vue-scoped-css/no-deprecated-v-enter-v-leave-class](./no-deprecated-v-enter-v-leave-class.md) | disallow v-enter and v-leave classes. | |
6566
| [vue-scoped-css/require-selector-used-inside](./require-selector-used-inside.md) | disallow selectors defined that is not used inside `<template>` | |
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
pageClass: "rule-details"
3+
sidebarDepth: 0
4+
title: "vue-scoped-css/no-deprecated-v-enter-v-leave-class"
5+
description: "disallow v-enter and v-leave classes."
6+
---
7+
# vue-scoped-css/no-deprecated-v-enter-v-leave-class
8+
9+
> disallow v-enter and v-leave classes.
10+
11+
- :gear: This rule is included in `"plugin:vue-scoped-css/all"`.
12+
13+
## :book: Rule Details
14+
15+
This rule reports the use of the `v-enter` and `v-leave` classes renamed in Vue 3 as an error.
16+
You should change it to use the `v-enter-from` and `v-leave-from` classes instead.
17+
18+
See [Migration from Vue 2 - Transition Class Change] for more details.
19+
20+
<eslint-code-block :rules="{'vue-scoped-css/no-deprecated-v-enter-v-leave-class': ['error']}">
21+
22+
```vue
23+
<template>
24+
<Transition><div v-if="foo"/></Transition>
25+
<Transition name="fade"><div v-if="foo"/></Transition>
26+
</template>
27+
<style scoped>
28+
/* ✗ BAD */
29+
.v-enter {}
30+
.v-leave {}
31+
.fade-enter {}
32+
.fade-leave {}
33+
34+
/* ✓ GOOD */
35+
.v-enter-from {}
36+
.v-leave-from {}
37+
.fade-enter-from {}
38+
.fade-leave-from {}
39+
</style>
40+
```
41+
42+
</eslint-code-block>
43+
44+
If you define both old and new in the same selector, no error will be reported.
45+
46+
<eslint-code-block :rules="{'vue-scoped-css/no-deprecated-v-enter-v-leave-class': ['error']}">
47+
48+
```vue
49+
<template>
50+
<Transition><div v-if="foo"/></Transition>
51+
</template>
52+
<style scoped>
53+
/* ✓ GOOD */
54+
.v-enter, .v-enter-from {}
55+
.v-leave, .v-leave-from {}
56+
</style>
57+
```
58+
59+
</eslint-code-block>
60+
61+
This rule also reports `enter-class` and `leave-class` props.
62+
63+
<eslint-code-block :rules="{'vue-scoped-css/no-deprecated-v-enter-v-leave-class': ['error']}">
64+
65+
```vue
66+
<template>
67+
<!-- ✗ BAD -->
68+
<Transition
69+
enter-class="my-enter"
70+
leave-class="my-leave">
71+
<div v-if="foo"/>
72+
</Transition>
73+
74+
<!-- ✓ GOOD -->
75+
<Transition
76+
enter-from-class="my-enter"
77+
leave-from-class="my-leave">
78+
<div v-if="foo"/>
79+
</Transition>
80+
81+
<!-- If you define both old and new, no error will be reported. -->
82+
<Transition
83+
enter-class="my-enter"
84+
enter-from-class="my-enter"
85+
leave-class="my-leave"
86+
leave-from-class="my-leave">
87+
<div v-if="foo"/>
88+
</Transition>
89+
</template>
90+
<style>
91+
.my-enter {}
92+
.my-leave {}
93+
</style>
94+
```
95+
96+
</eslint-code-block>
97+
98+
## :wrench: Options
99+
100+
Nothing.
101+
102+
## :books: Further reading
103+
104+
- [Migration from Vue 2 - Transition Class Change]
105+
106+
[Migration from Vue 2 - Transition Class Change]: https://v3.vuejs.org/guide/migration/transition.html
107+
108+
## Implementation
109+
110+
- [Rule source](https://github.com/future-architect/eslint-plugin-vue-scoped-css/blob/master/lib/rules/no-deprecated-v-enter-v-leave-class.ts)
111+
- [Test source](https://github.com/future-architect/eslint-plugin-vue-scoped-css/blob/master/tests/lib/rules/no-deprecated-v-enter-v-leave-class.js)

0 commit comments

Comments
 (0)