Thanks to visit codestin.com
Credit goes to eslint.vuejs.org

Skip to content

vue/no-async-in-computed-properties

disallow asynchronous actions in computed properties

  • ⚙️ This rule is included in all of "plugin:vue/essential", *.configs["flat/essential"], "plugin:vue/vue2-essential", *.configs["flat/vue2-essential"], "plugin:vue/strongly-recommended", *.configs["flat/strongly-recommended"], "plugin:vue/vue2-strongly-recommended", *.configs["flat/vue2-strongly-recommended"], "plugin:vue/recommended", *.configs["flat/recommended"], "plugin:vue/vue2-recommended" and *.configs["flat/vue2-recommended"].

Computed properties and functions should be synchronous. Asynchronous actions inside them may not work as expected and can lead to an unexpected behaviour, that's why you should avoid them. If you need async computed properties you might want to consider using additional plugin vue-async-computed

📖 Rule Details

This rule is aimed at preventing asynchronous methods from being called in computed properties and functions.

Now loading...
Now loading...

🔧 Options

js
{
  "vue/no-async-in-computed-properties": ["error", {
    "ignoredObjectNames": []
  }]
}
  • ignoredObjectNames: An array of object names that should be ignored when used with promise-like methods (.then(), .catch(), .finally()). This is useful for validation libraries like Zod that use these method names for non-promise purposes (e.g. z.catch()).

"ignoredObjectNames": ["z"]

Now loading...

📚 Further Reading

🚀 Version

This rule was introduced in eslint-plugin-vue v3.8.0

🔍 Implementation