Back to Biomejs

useVueConsistentDefinePropsDeclaration

src/content/docs/linter/rules/use-vue-consistent-define-props-declaration.mdx

latest4.5 KB
Original Source

import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.11` - Diagnostic Category: [`lint/nursery/useVueConsistentDefinePropsDeclaration`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - This rule belongs to the following domains: - [`vue`](/linter/domains#vue) - Sources: - Same as [`vue/define-props-declaration`](https://eslint.vuejs.org/rules/define-props-declaration)

How to configure

json
{
	"linter": {
		"rules": {
			"nursery": {
				"useVueConsistentDefinePropsDeclaration": "error"
			}
		}
	}
}

Description

Enforce consistent defineProps declaration style.

This rule enforces defineProps typing style which you should use type or runtime declaration.

Examples

Invalid

vue
<script setup lang="ts">
const props = defineProps({
  kind: { type: String },
});
</script>
<pre class="language-text"><code class="language-text">code-block.vue:1:15 <a href="https://biomejs.dev/linter/rules/use-vue-consistent-define-props-declaration">lint/nursery/useVueConsistentDefinePropsDeclaration</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This </span><span style="color: lightgreen;"><strong>defineProps</strong></span><span style="color: lightgreen;"> declaration uses </span><span style="color: lightgreen;"><strong>runtime</strong></span><span style="color: lightgreen;"> declaration.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>const props = defineProps(&#123; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong> kind: &#123; type: String &#125;, <strong><span style="color: Tomato;">&gt;</span></strong> <strong>3 │ </strong>&#125;); <strong> │ </strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>4 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">It should be defined using </span><span style="color: lightgreen;"><strong>type</strong></span><span style="color: lightgreen;"> declaration like </span><span style="color: lightgreen;"><strong>defineProps&lt;...&gt;()</strong></span><span style="color: lightgreen;">. </span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit </span><span style="color: lightgreen;"><a href="https://biomejs.dev/linter/#nursery">https://biomejs.dev/linter/#nursery</a></span><span style="color: lightgreen;"> for more information.</span> </code></pre>

Valid

vue
<script setup lang="ts">
const props = defineProps<{
  kind: string;
}>();
</script>
</TabItem> </Tabs>