Vue API should be called with arguments of correct types
- VUE_MISMATCHED_TYPE_OF_ARG
- Error
- Medium
- cwe, vue
This rule applies when Vue API is called with arguments of wrong types.
Because Vue API has the specification for its arguments, Vue will throw an error or output a warning message if the types of arguments are wrong.
Noncompliant Code Example
View with compliant examples side by side<script>
export default {
mounted() {
// VUE_MISMATCHED_TYPE_OF_ARG alarm because the first argument's type of '$watch()' should be string or function.
this.$watch(123, function (newVal, oldVal) {
// do something
});
}
}
</script>
Compliant Code Example
View with noncompliant examples side by side<script>
export default {
mounted() {
this.$watch('123', function (newVal, oldVal) {
// do something
});
}
}
</script>
Version
This rule was introduced in DeepScan 1.14.0-beta.