JS.VUE.NO.DEPRECATED.PROPS.DEFAULT.THIS

Disallow props default function 'this' access

Rule Details

This rule reports the use of this within the props default value factory functions. In Vue.js 3.0.0+, props default value factory functions no longer have access to this.

See Migration Guide - Props Default Function this Access (https://v3-migration.vuejs.org/breaking-changes/props-default-this.html) for more details.

{'vue/no-deprecated-props-default-this': ['error']}

Copy
<script>
export default {
  props: {
    a: String,
    b: {
      default () {
        /* BAD */
        return this.a
      }
    }
  }
}
</script>

{'vue/no-deprecated-props-default-this': ['error']}

Copy
<script>
export default {
  props: {
    a: String,
    b: {
      default (props) {
        /* GOOD */
        return props.a
      }
    }
  }
}
</script>

Options

Nothing.

Further Reading

  • Migration Guide - Props Default Function this Access (https://v3-migration.vuejs.org/breaking-changes/props-default-this.html)

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/