-
-
Notifications
You must be signed in to change notification settings - Fork 697
Open
Labels
Description
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: v9.39.1
- eslint-plugin-vue version: 10.6.2
- Vue version: ^3.5.25
- Node version: v20.19.6
- Operating System: Linux 6.14.0-36-generic
Please show your full configuration:
import pluginVue from 'eslint-plugin-vue';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
import vueParser from 'vue-eslint-parser';
export default [
...pluginVue.configs['flat/recommended'],
{
rules: {
'vue/define-props-declaration': 'off',
'vue/require-default-prop': 'off',
'vue/multi-word-component-names': 'off',
},
},
{
files: ['*.vue', '**/*.vue'],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tsparser,
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': tseslint,
},
rules: {
'vue/define-props-destructuring': 'error',
},
},
];
What did you do?
Import a type and use it in defineProps. This does not show an error for not destructuring. It does report the error for a locally defined type or not using a type.
<template>
<div>
<h1>{{ title }}</h1>
<p>{{ message }}</p>
</div>
</template>
<script setup lang="ts">
import type { Props } from './UsingTypeCorrectError.vue';
const props = defineProps<Props>();
</script>
What did you expect to happen?
Show an error because it should be:
<template>
<div>
<h1>{{ title }}</h1>
<p>{{ message }}</p>
</div>
</template>
<script setup lang="ts">
import type { Props } from './UsingTypeCorrectError.vue';
const {title, message} = defineProps<Props>();
</script>
What actually happened?
Should report 3 errors for the example repo but only reports 2
/home/rogier/dev/personal/eslint-vue-demo/NoTypeCorrectError.vue
10:15 error Prefer destructuring from `defineProps` directly vue/define-props-destructuring
/home/rogier/dev/personal/eslint-vue-demo/UsingTypeCorrectError.vue
13:15 error Prefer destructuring from `defineProps` directly vue/define-props-destructuring
✖ 2 problems (2 errors, 0 warnings)
NoTypeNoError.vue- ✅ Passes the rule (uses destructuring with defineProps, plain JavaScript)NoTypeCorrectError.vue- ✅ Reports violating the rule (doesn't use destructuring, plain JavaScript)UsingTypeCorrectError.vue- ✅ Reports violating the rule (doesn't use destructuring, TypeScript with inline interface)UsingImportedTypeMissingError.vue- ❌ Doesn't report violating the rule (doesn't use destructuring, TypeScript with imported type)
Repository to reproduce this issue
FloEdelmann