Skip to content

vue/no-expose-after-await false positives #1895

Closed
@AndreasNasman

Description

@AndreasNasman

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.15.0
  • eslint-plugin-vue version: 9.0.0
  • Node version: 16.14.2
  • Operating System: macOS Monterey

Please show your full configuration:

module.exports = {
  env: {
    node: true,
  },
  extends: ['plugin:vue/vue3-recommended', 'eslint:recommended'],
  parserOptions: {
    ecmaVersion: 'latest',
  },
  root: true,
};

What did you do?

<script setup>
import { onMounted, ref, watch } from 'vue';
await new Promise((r) => {
  setTimeout(r, 1000);
});
onMounted(() => {
  console.log('mounted child');
});

let foo = ref('');

watch(foo, () => {
  console.log('foo', foo);
});

function bar() {
  console.log('bar');
}
bar();
</script>

What did you expect to happen?
No violations should be reported.

What actually happened?

/home/projects/vitejs-vite-vaxgjy/src/ChildComponent.vue
   6:1  error  `onMounted` is forbidden after an `await` expression  vue/no-expose-after-await
  12:1  error  `watch` is forbidden after an `await` expression      vue/no-expose-after-await
  19:1  error  `bar` is forbidden after an `await` expression        vue/no-expose-after-await

✖ 3 problems (3 errors, 0 warnings)

Repository to reproduce this issue
https://stackblitz.com/edit/vitejs-vite-vaxgjy?file=src/ChildComponent.vue

Steps to reproduce:

  1. Open a new terminal tab.
  2. Run npm run lint.

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