unicorn/no-empty-file
Disallow files that contain no code
A file without code does nothing. It's usually left over from a refactor, or someone created it and never filled it in. It still shows up in searches and in the file tree, and importing it works but gives you nothing.
A file counts as empty if it only has whitespace, comments, directives such as "use strict", lone semicolons, or empty blocks.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/no-empty-file" = "error" # or "warn"Examples#
example.js1 problem
// TODO: move the date helpers hereEmpty files are not allowed.example.js1 problem
"use strict";Empty files are not allowed.example.jsNo problems
export function formatDate(date) {
return date.toISOString().slice(0, 10);
}A file with a /// comment isn't reported, because /// <reference> does something in TypeScript:
example.tsNo problems
/// <reference types="bun" />export {} is code. It makes the file a module:
example.tsNo problems
export {};