Rule proposition: No async in computed property functions
See original GitHub issueA 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:
- Created 6 years ago
- Reactions:1
- Comments:10 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think we should cover first 3 examples, and the last one would be to detect presence of any of
then
,catch
orfinally
in allCallExpression
s inside computed property’s body. Bur I’m against checking argumentsresponse
andres
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 propertyactiveResponse
in which we’d like to call a utility function withresponse
argument, or short res. I had similar case withroute
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 😄Done in
v3.8.0
🚀 Thanks @armano2 for the hard work!