Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vue/no-lifecycle-after-await rule to support <script setup> #2291

Closed
cjpearson opened this issue Oct 5, 2023 · 1 comment
Closed

Comments

@cjpearson
Copy link
Contributor

What rule do you want to change?

no-lifecycle-after-await

Does this change cause the rule to produce more or fewer warnings?

More warnings

How will the change be implemented? (New option, new default behavior, etc.)?

It will change the behavior of the existing I rule. I think no options should be necessary.

Please provide some example code that this change will affect:

<script setup>
import { onMounted } from 'vue'
/* ✓ GOOD */
onMounted(() => { /* ... */ })

await doSomething()

/* ✗ BAD */
onMounted(() => { /* ... */ })
</script>

What does the rule currently do for this code?

There are no errors.

What will the rule do after it's changed?

The second onMounted will trigger an error

Additional context

This rule currently works only when using a setup function.

<script>
import { onMounted } from 'vue'
export default {
  async setup() {
    /* ✓ GOOD */
    onMounted(() => { /* ... */ })

    await doSomething()

    /* ✗ BAD */
    onMounted(() => { /* ... */ })
  }
}
</script>

I think the fix would be similar to the one done for no-expose-after-wait. #1885

@ota-meshi
Copy link
Member

See #1885 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants