Skip to content

Commit 47fad0e

Browse files
committed
fix(linter/no-empty-file): false positive with empty file with triple slash directive (#12293)
1 parent 5e428a4 commit 47fad0e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/oxc_linter/src/rules/unicorn/no_empty_file.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ fn has_triple_slash_directive(ctx: &LintContext<'_>) -> bool {
7474
continue;
7575
}
7676
let text = ctx.source_range(comment.content_span());
77-
if text.starts_with("///") {
77+
78+
// `comment.content_span` doesn't include the leading `//` of the comment
79+
if text.starts_with('/') {
7880
return true;
7981
}
8082
}
@@ -110,6 +112,7 @@ fn test() {
110112
r"(() => {})()",
111113
"(() => {})();",
112114
"/* eslint-disable no-empty-file */",
115+
r#"/// <reference types="vite/client" />"#,
113116
];
114117

115118
let fail = vec![

0 commit comments

Comments
 (0)