From f2d3f3a2099877bb65050c415c97c289e65a4267 Mon Sep 17 00:00:00 2001 From: Aryeh Berman Date: Tue, 3 Dec 2024 13:10:53 -0500 Subject: [PATCH] feat: Add a test case to require-valid-default-prop The documentation for Vue props, as well as the `require-valid-default-prop` rule, are not clear if setting a default value of `null` to a prop with type `Object` requires a factory function. On one hand, `typeof null === 'object'`. On the other hand, the reason for using a factory function is so each instance of the prop has a different object reference, whereas `null` is always the same reference anyway. This adds a valid test case for setting a default value of `null` to a prop with type `Object` without a factory function. The test passes, so it's evident that `null` does not require a factory function. --- tests/lib/rules/require-valid-default-prop.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/lib/rules/require-valid-default-prop.js b/tests/lib/rules/require-valid-default-prop.js index 238460876..a724d36f7 100644 --- a/tests/lib/rules/require-valid-default-prop.js +++ b/tests/lib/rules/require-valid-default-prop.js @@ -108,6 +108,7 @@ ruleTester.run('require-valid-default-prop', rule, { foo: { type: String, default () { return Foo } }, foo: { type: Number, default () { return Foo } }, foo: { type: Object, default () { return Foo } }, + foo: { type: Object, default: null }, } })`, languageOptions