Skip to content

vue/require-default-prop doesn't trigger with props destructure #2725

Closed
@hartbit

Description

@hartbit

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: 9.21.0
  • eslint-plugin-vue version: 10.0.0
  • Vue version: 3.5.13
  • Node version: 22.14.0
  • Operating System: macOS

Please show your full configuration:

import pluginVue from "eslint-plugin-vue";
import { defineConfigWithVueTs, vueTsConfigs } from "@vue/eslint-config-typescript";

export default defineConfigWithVueTs(
  {
    name: "app/files-to-lint",
    files: ["**/*.{ts,mts,tsx,vue}"],
  },

  {
    name: "app/files-to-ignore",
    ignores: ["**/dist/**", "**/dist-ssr/**", "**/coverage/**"],
  },

  pluginVue.configs["flat/recommended"],
  vueTsConfigs.recommended
);

What did you do?

const { msg } = defineProps<{
  msg?: string;
}>();

What did you expect to happen?
I switched from using the withDefaults to the new props destructure syntax and I expected the vue/require-default-prop to continue to check when defaults were not defined in the destructured object. I expected the above example to complain that I did not define defaults for msg.

What actually happened?
I got no errors in the above example.

Repository to reproduce this issue
https://github.com/hartbit/eslint-require-default-prop-destructured-issue

  • The src/components/HelloWorld.vue component generates a warning, as expected, as it uses withDefaults,
  • The src/components/HelloWordIssue.vue component does not generate a warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions