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

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

Closed
2 tasks done
AndreasNasman opened this issue May 18, 2022 · 1 comment · Fixed by #1896
Closed
2 tasks done

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

AndreasNasman opened this issue May 18, 2022 · 1 comment · Fixed by #1896

Comments

@AndreasNasman
Copy link

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.
@AndreasNasman
Copy link
Author

It seems like vue/no-expose-after-await is a bit too aggressive after #1885 and reports false positives for all functions after the first await; only expose and defineExpose should be caught.

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

Successfully merging a pull request may close this issue.

1 participant