src/content/docs/linter/rules/no-empty-source.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="GraphQL" icon="seti:graphql"> ## Summary - Rule available since: `v2.2.7` - Diagnostic Category: [`lint/suspicious/noEmptySource`](/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 [**warning**](/reference/diagnostics#warning). ## How to configure ```json title="biome.json" { "linter": { "rules": { "suspicious": { "noEmptySource": "error" } } } }## Description
Disallow empty sources.
A source containing only the following is considered empty:
- Whitespace (spaces, tabs or newlines)
- Comments
## Examples
### Invalid
```graphql
query Member {}
fragment StrippedMember on Member {}
allowCommentsWhether the comments should be marked as meaningful.
When this option has been set to true, a file with only comments is considered valid.
Default false
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": {
"options": {
"allowComments": true
}
}
}
}
}
}
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": "error"
}
}
}
}
Disallow empty sources.
A source containing only the following is considered empty:
/* Only comments */
a { }
allowCommentsWhether the comments should be marked as meaningful.
When this option has been set to true, a file with only comments is considered valid.
Default false
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": {
"options": {
"allowComments": true
}
}
}
}
}
}
/* Only comments */
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": "error"
}
}
}
}
Disallow empty sources.
A source containing only the following is considered empty:
// Only comments
/* Only comments */
'use strict';
;
{
}
#!/usr/bin/env node
const x = 0;
'use strict';
const x = 0;
;;
const x = 0;
{
const x = 0;
}
allowCommentsWhether the comments should be marked as meaningful.
When this option has been set to true, a file with only comments is considered valid.
Default false
{
"linter": {
"rules": {
"suspicious": {
"noEmptySource": {
"options": {
"allowComments": true
}
}
}
}
}
}
/* Only comments */