|
| 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