noEmptySource
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noEmptySource
- This rule doesn’t have a fix.
- The default severity of this rule is information.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noEmptySource": "error" } } }}
Description
Section titled “Description”Disallow empty sources.
A source containing only the following is considered empty:
- Whitespace (spaces, tabs or newlines)
- Comments
Examples
Section titled “Examples”Invalid
Section titled “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.
code-block.graphql:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Expected a definition but instead found ‘Only comments’.
> 1 │ Only comments
│ ^^^^^^^^^^^^^
2 │
ℹ Expected a definition here.
> 1 │ Only comments
│ ^^^^^^^^^^^^^
2 │
query Member {}
fragment StrippedMember on Member {}
Options
Section titled “Options”allowComments
Section titled “allowComments”Whether 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": { "nursery": { "noEmptySource": { "options": { "allowComments": true } } } } }}
Invalid
Section titled “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.
code-block.graphql:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Expected a definition but instead found ‘Only comments’.
> 1 │ Only comments
│ ^^^^^^^^^^^^^
2 │
ℹ Expected a definition here.
> 1 │ Only comments
│ ^^^^^^^^^^^^^
2 │
Related links
Section titled “Related links”Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noEmptySource
- This rule doesn’t have a fix.
- The default severity of this rule is information.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noEmptySource": "error" } } }}
Description
Section titled “Description”Disallow empty sources.
A source containing only the following is considered empty:
- Whitespace (spaces, tabs or newlines)
- Comments
Examples
Section titled “Examples”Invalid
Section titled “Invalid”
code-block.json:2:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Expected an array, an object, or a literal but instead found the end of the file.
> 2 │
│
ℹ Expected an array, an object, or a literal here.
> 2 │
│
// Only comments
code-block.jsonc:2:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Expected an array, an object, or a literal but instead found the end of the file.
1 │ // Only comments
> 2 │
│
ℹ Expected an array, an object, or a literal here.
1 │ // Only comments
> 2 │
│
{ }
Options
Section titled “Options”allowComments
Section titled “allowComments”Whether 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": { "nursery": { "noEmptySource": { "options": { "allowComments": true } } } } }}
Invalid
Section titled “Invalid”
code-block.jsonc:2:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Expected an array, an object, or a literal but instead found the end of the file.
> 2 │
│
ℹ Expected an array, an object, or a literal here.
> 2 │
│
// Only comments
code-block.jsonc:2:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Expected an array, an object, or a literal but instead found the end of the file.
1 │ // Only comments
> 2 │
│
ℹ Expected an array, an object, or a literal here.
1 │ // Only comments
> 2 │
│
Related links
Section titled “Related links”Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noEmptySource
- This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
stylelint/no-empty-source
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noEmptySource": "error" } } }}
Description
Section titled “Description”Disallow empty sources.
A source containing only the following is considered empty:
- Whitespace (spaces, tabs or newlines)
- Comments
Examples
Section titled “Examples”Invalid
Section titled “Invalid”
code-block.css: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.
/* Only comments */
code-block.css:2:1 lint/nursery/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ An empty source is not allowed.
1 │ /* Only comments */
> 2 │
│
ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.
a { }
Options
Section titled “Options”allowComments
Section titled “allowComments”Whether 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": { "nursery": { "noEmptySource": { "options": { "allowComments": true } } } } }}
Invalid
Section titled “Invalid”
code-block.css: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.
/* Only comments */
Related links
Section titled “Related links”Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noEmptySource
- This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
unicorn/no-empty-file
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noEmptySource": "error" } } }}
Description
Section titled “Description”Disallow empty sources.
A source containing only the following is considered empty:
- Whitespace (spaces, tabs or newlines)
- Comments
- Directives
- Empty statements
- Empty block statements
- Hashbang
Examples
Section titled “Examples”Invalid
Section titled “Invalid”
code-block.js: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.
// Only comments
code-block.js:2:1 lint/nursery/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ An empty source is not allowed.
1 │ // Only comments
> 2 │
│
ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.
/* Only comments */
code-block.js:2:1 lint/nursery/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ An empty source is not allowed.
1 │ /* Only comments */
> 2 │
│
ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.
'use strict';
code-block.js:1:1 lint/nursery/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ An empty source is not allowed.
> 1 │ ‘use strict’;
│ ^^^^^^^^^^^^^
2 │
ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.
;
code-block.js:1:1 lint/nursery/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ An empty source is not allowed.
> 1 │ ;
│ ^
2 │
ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.
{}
code-block.js:1:1 lint/nursery/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ An empty source is not allowed.
> 1 │ {
│ ^
> 2 │ }
│ ^
3 │
ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.
#!/usr/bin/env node
code-block.js:1:1 lint/nursery/noEmptySource ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ An empty source is not allowed.
> 1 │ #!/usr/bin/env node
│ ^^^^^^^^^^^^^^^^^^^
2 │
ℹ Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it.
const x = 0;
'use strict';const x = 0;
;;const x = 0;
{ const x = 0;}
Options
Section titled “Options”allowComments
Section titled “allowComments”Whether 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": { "nursery": { "noEmptySource": { "options": { "allowComments": true } } } } }}
Invalid
Section titled “Invalid”
code-block.js: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.
/* Only comments */
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.