Skip to content

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

Closed
@cjpearson

Description

@cjpearson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions