Return value of function-typed Vue options should be a valid type

  • Error
  • Medium
  • vue

This rule applies when the return value of a function-typed Vue option is invalid.

If an invalid value is returned from a function-typed Vue option, it may cause a problem when Vue uses the value. Even when no immediate problem occurs, the value becomes meaningless.

The options which cause problem for an invalid return value are listed below with the valid return values:

  1. data(): Object
  2. setup(): Object, Function, or undefined
  3. render() for non-functional components: any value except Array (Vue 2.x only)
  4. renderError(): any value except Array
  5. errorCaptured() lifecycle hook: false, undefined, or null

Vue outputs a warning message in the cases of data(), render(), and renderError().

Also, this rule checks the following lifecycle hooks which need no return value:

  1. beforeCreate()
  2. created()
  3. beforeMount()
  4. mounted()
  5. beforeUpdate()
  6. updated()
  7. activated()
  8. deactivated()
  9. beforeDestroy() (Vue 2.x) or beforeUnmount() (Vue 3.x)
  10. destroyed() (Vue 2.x) or unmounted() (Vue 3.x)
  11. renderTracked()
  12. renderTriggered()

In the above cases, returning a value has no effect.

Noncompliant Code Example

View with compliant examples side by side
export default {
  data() {
    return 'data'; // VUE_BAD_API_RETURN_VALUE alarm because 'data()' does not return an object.
  beforeCreate() {
    return true; // VUE_BAD_API_RETURN_VALUE alarm because 'beforeCreate()' does not need a return value.

Compliant Code Example

View with noncompliant examples side by side
export default {
  data() {
    return { msg: 'hi' };
  beforeCreate() {
    // do something


This rule was introduced in DeepScan 1.14.0-beta.


Was this documentation helpful?