Skip to content

noEmptySource

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"nursery": {
"noEmptySource": "error"
}
}
}
}

¥Description

禁止使用空源。

¥Disallow empty sources.

仅包含以下内容的源被视为空:

¥A source containing only the following is considered empty:

  • 空格(空格、制表符或换行符)

    ¥Whitespace (spaces, tabs or newlines)

  • 评论

    ¥Comments

¥Examples

¥Invalid

code-block.graphql:2:1 lint/nursery/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

query Member {}
fragment StrippedMember on Member {}

¥Options

注释是否应标记为有意义。当此选项设置为 true 时,仅包含注释的文件也被视为有效。

¥Whether the comments should be marked as meaningful. When this option has been set to true, a file with only comments is considered valid.

默认 false

¥Default false

biome.json
{
"linter": {
"rules": {
"nursery": {
"noEmptySource": {
"options": {
"allowComments": true
}
}
}
}
}
}

¥Invalid

code-block.graphql:2:1 lint/nursery/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

¥Related links