{"record":{"id":"6963e149ebd1b81e","repo":"oxc-project/oxc","slug":"relative-imports-before-absolute-imports-are-prohi","errorCode":null,"errorMessage":"Relative imports before absolute imports are prohibited","messagePattern":"Relative imports before absolute imports are prohibited","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/import/first.rs","lineNumber":20,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn first_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Import statements must come first\")\n        .with_help(\"Move import statement to the top of the file\")\n        .with_label(span)\n}\n\nfn absolute_first_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Relative imports before absolute imports are prohibited\")\n        .with_help(\"Move absolute import above relative import\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize, Serialize)]\npub struct First(AbsoluteFirst);\n\n#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)]\n#[serde(rename_all = \"kebab-case\")]\nenum AbsoluteFirst {\n    /// Forces absolute imports to be listed before relative imports.\n    ///\n    /// Examples of **incorrect** code for this rule with `\"absolute-first\"`:\n    /// ```js\n    /// import { x } from './foo';\n    /// import { y } from 'bar'\n    /// ```\n    ///","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/first.rs#L2-L38","documentation":"Fires from import/first with the 'absolute-first' option enabled when a relative import appears before an absolute (package/bare specifier) import. The diagnostic labels the relative import's span; enabling absolute-first is what activates this check.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/import/first.rs:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reorder imports so absolute/package imports come before relative ones","Disable the absolute-first option if the ordering is intentional"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}