{"record":{"id":"850f1198197d1196","repo":"oxc-project/oxc","slug":"do-not-import-modules-using-an-absolute-path","errorCode":null,"errorMessage":"Do not import modules using an absolute path","messagePattern":"Do not import modules using an absolute path","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/import/no_absolute_path.rs","lineNumber":22,"sourceCode":"use serde_json::Value;\n\nuse oxc_ast::{\n    AstKind,\n    ast::{Argument, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_absolute_path_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not import modules using an absolute path\")\n        .with_help(\"Replace the absolute path with a relative path or a module alias.\")\n        .with_label(span)\n}\n\n// <https://github.com/import-js/eslint-plugin-import/blob/v2.31.0/docs/rules/no-absolute-path.md>\n#[derive(Debug, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoAbsolutePath {\n    /// If set to `true`, dependency paths for ES module import statements will be resolved:\n    ///\n    /// ```js\n    /// import foo from '/foo'; // reported\n    /// ```\n    esmodule: bool,\n    /// If set to `true`, dependency paths for CommonJS-style require calls will be resolved:\n    ///\n    /// ```js\n    /// var foo = require('/foo'); // reported","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/no_absolute_path.rs#L4-L40","documentation":"Fires from import/no-absolute-path when a module specifier is an absolute filesystem path (e.g. '/usr/lib/foo' or 'C:\\\\...'). The run visitor detects absolute paths in import declarations and require() calls and labels the span, suggesting a relative path or module alias instead.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/import/no_absolute_path.rs:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the absolute path with a relative path","Configure and use a module alias (bundler/tsconfig paths) for stable imports"],"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"}