question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposition: No async in computed property functions

See original GitHub issue

A common issue that beginners run into is relying on async code in a computed property function, even though we warn about it in the docs. This might not be possible to identify 100% of the time, but it would be nice for the linter to warn about:

  • async/await
  • passing a function as a function argument (covers promises and callbacks)

Am I missing any cases where either of the above would actually be valid inside a computed property function?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
michalsnikcommented, Jun 28, 2017

I think we should cover first 3 examples, and the last one would be to detect presence of any of then, catch or finally in all CallExpressions inside computed property’s body. Bur I’m against checking arguments response and res as they might be used even if the body has nothing to do with async computing. For example application has a module that gathers users’ responses for a given topic, than we could have a computed property activeResponse in which we’d like to call a utility function with response argument, or short res. I had similar case with route in other plugin. I thought it’s enough to check for that name and then someone had an app with generating routes on google maps 😄

0reactions
michalsnikcommented, Jul 23, 2017

Done in v3.8.0 🚀 Thanks @armano2 for the hard work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue/no-async-in-computed-properties
This rule is aimed at preventing asynchronous methods from being called in computed properties and functions.
Read more >
Async call for computed property - Vue.js - Stack Overflow
I'm having an issue though trying to make an async call to return data for a computed property.
Read more >
How To Use Asynchronous Computed Properties in Vue.js ...
Learn how to use vue-async-computed in Vue projects for asynchronous computed properties.
Read more >
[Amendment] SE-0296: Allow overloads that differ only in async
Hello Swift Community, We are starting a review for an amendment to the accepted proposal SE-0296 "async/await". The review runs from now ...
Read more >
async computed property for Vue 3? : r/vuejs - Reddit
But below you do have an incorrect assumption that a computed could be used. OP explicitly has said they need async data -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found