{"record":{"id":"0ad37eb1c0d37472","repo":"oxc-project/oxc","slug":"empty-files-are-not-allowed","errorCode":null,"errorMessage":"Empty files are not allowed.","messagePattern":"Empty files are not allowed\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"info","filePath":"crates/oxc_linter/src/rules/unicorn/no_empty_file.rs","lineNumber":13,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    context::{ContextHost, LintContext},\n    loader::LINT_PARTIAL_LOADER_EXTENSIONS,\n    rule::Rule,\n    utils::is_empty_stmt,\n};\n\nfn no_empty_file_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Empty files are not allowed.\")\n        .with_help(\"Delete this file or add some code to it.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoEmptyFile;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallows files that do not contain any meaningful code.\n    ///\n    /// This includes files that consist only of:\n    /// - Whitespace\n    /// - Comments\n    /// - Directives (e.g., `\"use strict\"`)\n    /// - Empty statements (`;`)\n    /// - Empty blocks (`{}`)","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs#L1-L31","documentation":"Diagnostic from the oxlint rule `unicorn/no-empty-file` (category: correctness). A file counts as empty when every top-level statement is non-executable: only whitespace, comments, directives like `'use strict'`, empty statements `;`, empty blocks `{}`, or a lone hashbang. Such files are usually accidental (bad merges, emptied stubs, scaffolding leftovers) and mislead both readers and tooling. Files whose only content is a triple-slash directive (`/// <reference ...>`) are exempt; disable comments within the first 100 characters of the file are honored.","triggerScenarios":"A source file containing only `// comment`, `;`, `{}`, `'use strict';`, a hashbang, or nothing at all. Any real statement, expression, or export makes the file pass; partial-loader extensions are skipped entirely.","commonSituations":"Placeholder `index.js` committed before code exists; a file emptied when its contents moved elsewhere; scaffolding/generators producing stub files; hygiene sweeps after enabling the unicorn preset.","solutions":["Delete the file if nothing belongs in it","Add the intended code (even a single export is enough)","If a placeholder is genuinely required, ignore the path in .oxlintrc.json or put an inline disable comment at the top of the file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# find candidate empty files before linting\nfind src -type f \\( -name '*.js' -o -name '*.ts' \\) -size -2c","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete stub files immediately after scaffolding, or fill them in the same commit","Watch for files emptied by moves/refactors — git history keeps the content","Keep triple-slash reference files; they are exempt by design"],"tags":["files","code-hygiene","oxlint"],"backgroundTag":"empty-source-file","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}