vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.47k stars 667 forks source link

`require-typed-object-prop` reports on non-TypeScript `<script setup>` #2503

Closed andreww2012 closed 4 months ago

andreww2012 commented 4 months ago

Checklist

Tell us about your environment

Please show your full configuration:

What did you do?

Sorry for not filling out everything, I think the problem is straightforward and easily reproducible: require-typed-object-prop does not respect the lang attribute on <script setup> and expects type annotation to be present in plain JS code.

Just insert the following in the playground on this rule's page:

<script setup>
defineProps({
  prop: Object,
})
</script>

I've read the limitations section on the rule's page saying it is not meant to be used in JS projects, but I have some with mixed codebase (mainly as a result of TS migration or adjusting someone else's components code written in JS) and I just felt like detecting the language is something that seems possible to me.

What did you expect to happen?

What actually happened?

Repository to reproduce this issue

FloEdelmann commented 4 months ago

Thanks for reporting, I can reproduce the issue. ~PR welcome to fix this!~ Nevermind, I created a fix myself.