oxc-project/oxc · error · OxcDiagnostic
Expected {count} empty line{line_suffix} after {keyword} sta
Error message
Expected {count} empty line{line_suffix} after {keyword} statement not followed by another {keyword}. What it means
Fires from import/newline-after-import when an import statement or require() call is not followed by the configured number of empty lines before subsequent code. The helper pluralizes 'line' from the count and interpolates whether the statement was an import or require; the labeled span covers the offending statement.
Source
Thrown at crates/oxc_linter/src/rules/import/newline_after_import.rs:29
use oxc_semantic::ScopeFlags;
use oxc_span::{GetSpan, Span};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{
AstNode,
ast_util::is_global_require_call,
context::LintContext,
rule::{DefaultRuleConfig, Rule},
};
fn newline_after_import_diagnostic(span: Span, count: usize, keyword: &str) -> OxcDiagnostic {
let line_suffix = if count == 1 { "" } else { "s" };
OxcDiagnostic::warn(format!(
"Expected {count} empty line{line_suffix} after {keyword} statement not followed by another {keyword}."
))
.with_label(span)
}
// <https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/newline-after-import.md>
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct NewlineAfterImport {
// Number of empty lines required after import statements.
count: u32,
// Whether the number of empty lines must be exactly `count`.
exact_count: bool,
// Whether comments should be considered when counting empty lines.
consider_comments: bool,
}
impl Default for NewlineAfterImport {
fn default() -> Self {
Self { count: 1, exact_count: false, consider_comments: false }
}View on GitHub (pinned to e1e7af627c)
Solutions
- Add the expected blank line(s) after the import or require statement
- Adjust the `count` option if a different spacing is preferred
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/import/newline_after_import.rs:29 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/5db51f6103a3619a.
Report an issue: GitHub.