unicorn/no-empty-file Correctness ​
What it does ​
Disallows files that do not contain any meaningful code.
This includes files that consist only of:
- Whitespace
- Comments
- Directives (e.g.,
"use strict"
) - Empty statements (
;
) - Empty blocks (
{}
) - Hashbangs (
#!/usr/bin/env node
)
Why is this bad? ​
Files with no executable or exportable content are typically unintentional or left over from refactoring. They clutter the codebase and may confuse tooling or developers by appearing to serve a purpose when they do not.
How to use ​
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny unicorn/no-empty-file
json
{
"rules": {
"unicorn/no-empty-file": "error"
}
}