Skip to content

vue/require-default-prop: false positive when pass withDefaults argument by reference #2993

@tilonorrinco

Description

@tilonorrinco

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.39.1
  • eslint-plugin-vue version: 10.5.1
  • Vue version: 3.5.25
  • Node version: 24.11.1
  • Operating System: Windows 10 pro 22H2

Please show your full configuration:

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

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

  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  pluginVue.configs['flat/recommended'],
  vueTsConfigs.recommended,
)

What did you do?

<script setup lang="ts">
defineOptions({ name: 'ExampleComponent' });

interface Props {
  optionalProp?: string;
}

const defaultsObj = {
  optionalProp: 'hello!',
}

withDefaults(defineProps<Props>(), defaultsObj);
</script>

What did you expect to happen?
No "vue/require-default-prop" error for "optionalProp"

What actually happened?

**\src\ExampleComponent.vue
5:3 warning Prop 'optionalProp' requires default value to be set vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

Repository to reproduce this issue

https://github.com/tilonorrinco/bug-vue-require-default-prop

Thanks in advance!

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