Skip to content

noEmptySource (GraphQL)

  • Rule available since: v2.2.7
  • Diagnostic Category: lint/suspicious/noEmptySource
  • 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 warning.
biome.json
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": "error"
}
}
}
}

Disallow empty sources.

A file is empty when it contains no GraphQL definitions. By default, whitespace and comments do not count as content.

code-block.graphql:2:1 lint/suspicious/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ An empty source is not allowed.

> 2 │
│

ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.

# Invalid comment
query Member {}
fragment StrippedMember on Member {}

Treats comments as meaningful content when set to true, so a comments-only file is valid. An entirely empty file remains invalid. Defaults to false.

biome.json
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": {
"level": "on",
"options": {
"allowComments": true
}
}
}
}
}
}
code-block.graphql:2:1 lint/suspicious/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ An empty source is not allowed.

> 2 │
│

ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.

# Valid comment