Skip to content

vue/component-api-style fails to detect api type when only options are defined. #2926

@npbenjohnson

Description

@npbenjohnson

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 <script setup> is supposed to be enabled.

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 <script setup>.

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

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