Skip to content

Rule Proposal: Ensure prop.type is an Object #323

Closed
@richardtallent

Description

@richardtallent

Please describe what the rule should do:

Ensure that the type key for a property is passed as an Object, not as a string.

What category of rule is this? (place an "X" next to just one item)

[ ] Enforces code style
[x] Warns about a potential error
[ ] Suggests an alternate way of doing something
[ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

props: {
	myFieldWithBadType: {
		type: "Object",
		default: function() {
			return {}
		},
	},
	myOtherFieldWithBadType: {
		type: "Number",
		default: 1,
	},
}

Why should this rule be included in ESLint (instead of a plugin)?

Passing a string to type rather than the name of the type results in a rather opaque error message from deep in the bowels of Vue, and it's an easy mistake to make.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions