eslint-plugin-vue
eslint-plugin-vue copied to clipboard
vue/component-api-style fails to detect api type when only options are defined.
Checklist
- [ x] I have tried restarting my IDE and the issue persists.
- [x ] I have read the FAQ and my problem is not listed.
Tell us about your environment
- ESLint version: 9.34.0
- eslint-plugin-vue version: 10.4.0
- Vue version: 3.5.21
- Node version: v20.19.4
- Operating System: Windows 11
Please show your full configuration:
{
...
rules: {
"vue/component-api-style": ["warn", ["script-setup"]],
}
}
What did you do?
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
// iPhone 6 Mockup
name: "PhoneMockup",
});
</script>
What did you expect to happen? Lint to fail due to component export in the file when only
What actually happened?
Code passed linting.
It appears detection work based on there being a "setup" or "data" member on the exported component to determine which api is being used, with <script setup> detection being the default case as opposed to an actual detection. Because this component only defines a name, no specific api is detected, so it passes validation even though it is not using
I verified that adding a "setup" or "data" member to the component does cause the rule report correctly that the api being used is not allowed.
Repository to reproduce this issue