feat(no-empty-file): add no-empty-file rule - #1520
Open
bartlomieju wants to merge 1 commit into
Open
Conversation
Member
Author
|
Verdict: LGTM on the logic — needs maintainer sign-off (RECOMMENDED/on-by-default) + one perf reorder. Not auto-merging (new rule). Faithful port of oxlint's Correctness — verified
Performance — worth reordering
Minor
Product decision (you flagged it)
Housekeeping: Logic is solid and well-tested. Blockers: confirm the RECOMMENDED tagging + the perf reorder; then good to land. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports oxlint's
unicorn/no-empty-filerule to deno_lint as a native Rustrule. It flags a file whose top-level body contains no real code — only
whitespace, comments, directive prologues (e.g.
"use strict";), emptystatements (
;), or empty blocks ({}).Top-level string-literal statements are treated as directives and counted
as empty, matching oxc; a string literal nested inside a block is a real
expression statement and keeps the file non-empty. Files consisting solely
of a triple-slash reference directive are exempt. The reported span is
capped at 100 characters so comment-heavy empty files don't produce a huge
diagnostic.
Reference rule:
https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs
(test fixtures ported from there; eslint-disable-specific fixtures were
dropped as they don't translate to deno_lint's ignore mechanism).
Note for maintainer review: this rule is tagged
RECOMMENDED(on bydefault for every user), consistent with it being a correctness rule.
Because of that, an empty file now produces a diagnostic by default, which
required updating the existing
empty_fileandempty_file_with_astframework tests in
src/lib.rsto expect the newno-empty-filediagnostic. Please confirm the on-by-default tagging is desired.