no-relative-parent-import
Disallow relative parent imports such as ".." and "../*".
Targeted pattern scopeโ
This rule reports module sources that traverse to parent directories using
patterns like .., ../**, ../../**, and deeper defaults.
It applies to import/export source strings and dynamic import strings.
What this rule reportsโ
This rule reports imports/exports that traverse parent directories. It helps enforce local-only imports or alias-based module boundaries.
Why this rule existsโ
Preventing parent-relative imports helps enforce bounded module layers and reduces coupling across directory boundaries.
โ Incorrectโ
import service from "../service";
export * from "../../utils";
โ Correctโ
import service from "./service";
import utils from "@/utils";
Deprecatedโ
- Lifecycle: Deprecated and frozen.
- Deprecated since:
v1.0.0 - Available until:
v2.0.0 - Use instead:
import/no-relative-parent-imports
Behavior and migration notesโ
This rule is deprecated in favor of
import/no-relative-parent-imports from eslint-plugin-import.
It reports only and does not provide an autofix.
Optionsโ
type Options = {
allow?: string[];
disallow?: string[];
};
Default disallow patterns include "..", "../**", "../..", "../../**", and deeper parent traversals.
Use allow for specific exceptions:
{
allow: ["../allowed-source"];
}
Statusโ
Use the Deprecated section above for lifecycle details.
Additional examplesโ
// default disallow includes ../** and ../../**
const mod = await import("../shared/mod");
// โ reported
import mod from "@/shared/mod";
// โ
valid when alias paths are allowed by your resolver
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-relative-parent-import": [
"error",
{ allow: ["../allowed-source"] },
],
},
},
];
When not to use itโ
Disable this rule if parent-relative imports are an accepted part of your module layout.
Package documentationโ
Rule catalog ID: R036
Further readingโ
Adoption resourcesโ
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.