Skip to content

Commit 444fcf0

Browse files
fix(linter): Fix false positive in vue/no-required-prop-with-default (#14066)
Closes #14056
1 parent 2186b28 commit 444fcf0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

crates/oxc_linter/src/rules/vue/no_required_prop_with_default.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,13 @@ fn collect_hash_from_variable_declarator(
217217
let key_hash: FxHashSet<String> = obj_pattern
218218
.properties
219219
.iter()
220-
.filter_map(|prop| prop.key.static_name())
220+
.filter_map(|prop| {
221+
if matches!(prop.value.kind, BindingPatternKind::AssignmentPattern(_)) {
222+
prop.key.static_name()
223+
} else {
224+
None
225+
}
226+
})
221227
.map(|key| key.to_string())
222228
.collect();
223229
Some(key_hash)
@@ -407,6 +413,18 @@ fn test() {
407413
use std::path::PathBuf;
408414

409415
let pass = vec![
416+
(
417+
r#"
418+
<script setup lang="ts">
419+
const { laps } = defineProps<{
420+
laps: unknown[];
421+
}>();
422+
</script>
423+
"#,
424+
None,
425+
None,
426+
Some(PathBuf::from("test.vue")),
427+
),
410428
(
411429
r#"
412430
<script setup lang="ts">

0 commit comments

Comments
 (0)