Skip to content

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

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

Closed
2 tasks done
hartbit opened this issue Mar 26, 2025 · 0 comments · Fixed by #2728
Closed
2 tasks done

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

hartbit opened this issue Mar 26, 2025 · 0 comments · Fixed by #2728
Labels

Comments

@hartbit
Copy link

hartbit commented Mar 26, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants