From 4ea6e5dc3bb293b3ab29742eb91185c8ddf59336 Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 5 Jan 2024 16:50:26 +0800 Subject: [PATCH] fix(linter): do not check empty file for vue / astro files (#1900) --- crates/oxc_linter/src/rules/unicorn/no_empty_file.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs b/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs index a0c9f5bef..88af7ca8b 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs @@ -6,7 +6,9 @@ use oxc_diagnostics::{ use oxc_macros::declare_oxc_lint; use oxc_span::Span; -use crate::{context::LintContext, rule::Rule, utils::is_empty_stmt}; +use crate::{ + context::LintContext, partial_loader::LINT_PARTIAL_LOADER_EXT, rule::Rule, utils::is_empty_stmt, +}; #[derive(Debug, Error, Diagnostic)] #[error("eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.")] @@ -38,6 +40,13 @@ declare_oxc_lint!( impl Rule for NoEmptyFile { fn run_once(&self, ctx: &LintContext) { + if ctx + .file_path() + .extension() + .is_some_and(|ext| LINT_PARTIAL_LOADER_EXT.contains(&ext.to_string_lossy().as_ref())) + { + return; + } let Some(root) = ctx.nodes().iter().next() else { return }; let AstKind::Program(program) = root.kind() else { return };