Skip to content

Rule proposal: no-expose-after-await #1704

Closed
@haoqunjiang

Description

@haoqunjiang

Please describe what the rule should do:

Similar to https://eslint.vuejs.org/rules/no-lifecycle-after-await.html and https://eslint.vuejs.org/rules/no-watch-after-await.html but applies to expose call. Because expose needs access to the current instance too.

What category should the rule belong to?

[ ] Enforces code style (layout)
[x] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<script>
import { defineComponent } from 'vue'

export defineComponent({
  setup(props, { expose }) {
    function sleep(ms) {
      return new Promise(resolve => setTimeout(resolve, ms));
	}
    await sleep(100)
    const sayHi = () = alert('hello')
    expose({ sayHi })
  }
})
</script>

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions