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-unused-emit-declarations reporting with defineEmits() and defineModel() compiler marcos #2351

Closed
2 tasks done
n0099 opened this issue Dec 18, 2023 · 3 comments
Closed
2 tasks done

Comments

@n0099
Copy link

n0099 commented Dec 18, 2023

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.56.0
  • eslint-plugin-vue version: 9.19.2
  • Node version: 21.4.0
  • Operating System: Windows 8.1

Please show your full configuration:

https://github.com/n0099/open-tbm/blob/1403ed2ffc75f200426def765ecb66142ed6c085/fe/.eslintrc.cjs

What did you do?

https://github.com/n0099/open-tbm/blob/1403ed2ffc75f200426def765ecb66142ed6c085/fe/src/components/Post/queryForm/widgets/InputNumericParam.vue#L22

defineEmits({
    'update:modelValue': (p: KnownNumericParams) =>
        _.isString(p.name) && _.isString(p.value)
        && numericParamSubParamRangeValues.includes(p.subParam.range)
});
const modelValue = defineModel<KnownNumericParams>({ required: true });

What did you expect to happen?
Not reporting since mutate the ref modelValue will emit the event update:modelValue under the hood.

What actually happened?

`update:modelValue` is defined as emit but never used.(vue/no-unused-emit-declarations)

Repository to reproduce this issue

https://github.com/n0099/open-tbm/blob/1403ed2ffc75f200426def765ecb66142ed6c085/fe

@FloEdelmann
Copy link
Member

Thanks for your report! defineModel still seems to be experimental: https://blog.vuejs.org/posts/vue-3-3#definemodel

So I think it's best to not support it in vue/no-unused-emit-declarations yet, since the implementation might have to change when it's released as stable, or removed again. So the workaround for now would be to disable the rule with an inline comment.

But if you fancy, you can implement support for defineModel in vue/no-unused-emit-declarations and open a PR, I'll review it.

@n0099
Copy link
Author

n0099 commented Dec 29, 2023

It's stable now: https://blog.vuejs.org/posts/vue-3-4#definemodel-is-now-stable vuejs/core#9598

@FloEdelmann
Copy link
Member

This is being tracked in #2130 now.

@FloEdelmann FloEdelmann closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2023
n0099 added a commit to n0099/open-tbm that referenced this issue Jan 17, 2024
…ns` due to vuejs/eslint-plugin-vue#2351

* fix `@typescript-eslint/no-unnecessary-condition` @ `<BiliBiilVote>`
@ fe

* update NuGet packages @ c#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants