Deprecated features of Vue should not be used
- VUE_DEPRECATED_FEATURE
- Error
- Medium
- vue
This rule applies when a deprecated or removed feature of Vue is used.
Currently, this rule checks the following features that are removed or replaced in Vue 3.0:
- Global API
new Vue()
(replaced bycreateApp()
)Vue.component()
(replaced byapp.component()
)Vue.directive()
(replaced byapp.directive()
)Vue.mixin()
(replaced byapp.mixin()
)Vue.use()
(replaced byapp.use()
)Vue.config
(replaced byapp.config
)Vue.observable()
(replaced byreactive()
)Vue.extend()
Vue.filter()
Vue.set()
Vue.delete()
- Config properties
ignoredElements
(replaced byisCustomElement()
)devtools
keyCodes
productionTip
- Options
el
(replaced byapp.mount()
)propsData
(replaced by the second argument ofcreateApp()
)beforeDestroy()
(replaced bybeforeUnmount()
)destroyed()
(replaced byunmounted()
)renderError()
filters
functional
model
- Instance methods
$mount()
(replaced byapp.mount()
)$destroy()
$on()
$once()
$off()
$set()
$delete()
- Instance properties
$listeners
(merged into$attrs
)$scopedSlots
(merged into$slots
)$children
- Special attributes
slot-scope
(replaced byv-slot
)inline-template
- Directive modifiers
v-bind.sync
(replaced byv-model
with an argument)v-bind.prop
v-on.native
- The numeric key codes of
v-on
- Custom directive hooks
bind()
(replaced bybeforeMount()
)inserted()
(replaced bymounted()
)componentUpdated()
(replaced byupdated()
)unbind()
(replaced byunmounted()
)update()
- Async component options
component
(replaced byloader
)loading
(replaced byloadingComponent
)error
(replaced byerrorComponent
)
- Directly using a factory function as an async component (replaced by
defineAsyncComponent()
) - Filters
- Functional templates
- The
createElement
parameter ofrender()
(replaced by the globally importedh
function) - The dot-delimited key paths of
$watch()
The following features deprecated in Vue 3.1 are checked also:
- Config properties
isCustomElement()
(replaced bycompilerOptions.isCustomElement()
)
- Options
delimiters
(replaced bycompilerOptions.delimiters
)
- Directive
v-is
(replaced byis
attribute withvue:
prefix)
Note: The application of this rule is limited to projects using Vue 3.x version.
Noncompliant Code Example
View with compliant examples side by sideimport Vue from 'vue';
import App from 'App.vue';
import Comp from 'Comp.vue';
Vue.component('Comp', Comp); // VUE_DEPRECATED_FEATURE alarm because 'Vue.component()' is deprecated.
new Vue({ // VUE_DEPRECATED_FEATURE alarm because 'new Vue()' is deprecated.
el: '#app', // VUE_DEPRECATED_FEATURE alarm because the 'el' option is deprecated.
render(createElement) { // VUE_DEPRECATED_FEATURE alarm because the 'createElement' parameter is deprecated.
return createElement(App);
},
beforeDestroy() { // VUE_DEPRECATED_FEATURE alarm because 'beforeDestroy()' is deprecated.
console.log("Destroying");
}
});
Compliant Code Example
View with noncompliant examples side by sideimport { createApp, h } from 'vue';
import App from 'App.vue';
import Comp from 'Comp.vue';
const app = createApp({
render() {
return h(App);
},
beforeUnmount() {
console.log("Unmounting");
}
});
app.component('Comp', Comp);
app.mount('#app');
Version
This rule was introduced in DeepScan 1.43.0.