Back to Biomejs

useGraphqlNamingConvention

src/content/docs/linter/rules/use-graphql-naming-convention.mdx

latest2.5 KB
Original Source

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

<Tabs> <TabItem label="GraphQL" icon="seti:graphql"> ## Summary - Rule available since: `v2.0.0` - Diagnostic Category: [`lint/style/useGraphqlNamingConvention`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Inspired from [`enum-values-all-caps`](https://github.com/cjoudrey/graphql-schema-linter?tab=readme-ov-file#enum-values-all-caps)

How to configure

json
{
	"linter": {
		"rules": {
			"style": {
				"useGraphqlNamingConvention": "error"
			}
		}
	}
}

Description

Validates that all enum values are capitalized.

By convention in GraphQL, enum values are all caps.

Examples

Invalid

graphql
enum MyEnum {
 value
}
<pre class="language-text"><code class="language-text">code-block.graphql:2:2 <a href="https://biomejs.dev/linter/rules/use-graphql-naming-convention">lint/style/useGraphqlNamingConvention</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Enum values should be in all caps.</span> <strong>1 │ </strong>enum MyEnum &#123; <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong> value <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>3 │ </strong>&#125; <strong>4 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Change the enum value to be in all caps.</span> </code></pre>

Valid

graphql
enum MyEnum {
 VALUE
}
</TabItem> </Tabs>