Skip to content

unicorn/no-empty-file Correctness

This rule is turned on by default.

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 using the config file or in the CLI, you can use:

json
{
  "rules": {
    "unicorn/no-empty-file": "error"
  }
}
bash
oxlint --deny unicorn/no-empty-file

References

Released under the MIT License.