Back to Biomejs

useConsistentGraphqlDescriptions

src/content/docs/linter/rules/use-consistent-graphql-descriptions.mdx

latest4.8 KB
Original Source

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

<Tabs> <TabItem label="GraphQL" icon="seti:graphql"> :::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.6` - Diagnostic Category: [`lint/nursery/useConsistentGraphqlDescriptions`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`@graphql-eslint/description-style`](https://the-guild.dev/graphql/eslint/rules/description-style)

How to configure

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

Description

Require all descriptions to follow the same style (either block or inline) to maintain consistency and improve readability across the schema.

Examples

style: block

Invalid

graphql
enum EnumValue {
  "this is a description"
  DEFAULT
}
<pre class="language-text"><code class="language-text">code-block.graphql:2:3 <a href="https://biomejs.dev/linter/rules/use-consistent-graphql-descriptions">lint/nursery/useConsistentGraphqlDescriptions</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unexpected inline description style.</span> <strong>1 │ </strong>enum EnumValue &#123; <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong> &quot;this is a description&quot; <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;">^</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>3 │ </strong> DEFAULT <strong>4 │ </strong>&#125; <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">To stay consistent within the project, write the description block style.</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

graphql
enum EnumValue {
  """
  this is a description
  """
  DEFAULT
}

Options

style

This option will specify the description style.

  • "block": Requires triple-quoted block descriptions ("""...""")
  • "inline": Requires single-quoted inline descriptions ("...")

Default "block"

json
{
	"linter": {
		"rules": {
			"nursery": {
				"useConsistentGraphqlDescriptions": {
					"options": {
						"style": "inline"
					}
				}
			}
		}
	}
}

graphql
enum EnumValue {
  """
  this is a description
  """
  DEFAULT
}
<pre class="language-text"><code class="language-text"></code></pre> </TabItem> </Tabs>