You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please describe what the rule should do:
The rule should notify when defineExpose is used after any top-level await. Doing so causes problems as described in this core Vue.js issue: vuejs/core#4930
What category should the rule belong to?
[x] Warns about a potential error (problem)
Provide 2-3 code examples that this rule should warn about:
// Example 1
...
<scriptsetup>...constfoo= { bar:'baz' };awaitasyncOperation();defineExpose({ foo }); // `defineExpose` should be called before any top-level `await`....</script>
...
// Example 2
...
<scriptsetup>...awaitasyncOperation();constfoo= { bar:'baz' };defineExpose({ foo }); // `defineExpose` should be called before any top-level `await`....</script>
...
Additional context
The current workaround is to manually remember to place all awaits after defineExpose. Forgetting to do so leads to problems that are hard to debug. In the context of my examples, a JavaScript error would be thrown when foo is used (foo is not defined or similar) in some other component and it's unclear the source of the problem is actually in the component defining foo.
The rule vue/no-expose-after-await should already catch this case. It is currently uncategorized and has to be enabled manually. It will be added to all Vue 3 preset configs in the next major version: #1848
Could you please enable it manually and check whether it reports all problematic cases?
I scaffolded a new Vue project with npm init vue@latest and it seems to only work for regular script components taking expose as a setup parameter, not script setup that uses defineExpose.
I upgraded the ESLint and eslint-plugin-vue versions to the latest stable releases, 8.14.0 and 8.7.1 respectively, so it's present in the latest stable versions.
Please describe what the rule should do:
The rule should notify when
defineExpose
is used after any top-levelawait
. Doing so causes problems as described in this core Vue.js issue:vuejs/core#4930
What category should the rule belong to?
[x] Warns about a potential error (problem)
Provide 2-3 code examples that this rule should warn about:
Additional context
The current workaround is to manually remember to place all
await
s afterdefineExpose
. Forgetting to do so leads to problems that are hard to debug. In the context of my examples, a JavaScript error would be thrown whenfoo
is used (foo is not defined
or similar) in some other component and it's unclear the source of the problem is actually in the component definingfoo
.The problem seems challenging to fix in Vue.js itself:
vuejs/core#4930 (comment)
The text was updated successfully, but these errors were encountered: