Skip to main content

no-sibling-import

Disallow sibling-file imports from the current directory.

Targeted pattern scopeโ€‹

This rule checks module source strings in:

  • import ... from "..."
  • export ... from "..."
  • export * from "..."
  • dynamic import("...")

It reports sources matching ./* by default.

It is built on the same glob-based import-pattern engine as disallow-import.

What this rule reportsโ€‹

This rule reports source paths that match configured disallow glob patterns and are not exempted by allow patterns.

Why this rule existsโ€‹

Disallowing sibling imports can enforce stricter layering where modules import through explicit public boundaries instead of lateral file coupling.

โŒ Incorrectโ€‹

import value from "./source";

โœ… Correctโ€‹

import value from "../source";

Behavior and migration notesโ€‹

This rule reports only and does not provide an autofix.

Default disallow is ./*, but you can override with custom allow and disallow patterns.

Optionsโ€‹

type Options = {
allow?: string[];
disallow?: string[];
};

Default:

{ "disallow": ["./*"] }

Additional examplesโ€‹

// default disallow: ["./*"]
export { value } from "./value";
// โŒ reported

export { value } from "../value";
// โœ… valid

await import("./runtime");
// โŒ reported

ESLint flat config exampleโ€‹

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-sibling-import": "error",
},
},
];

When not to use itโ€‹

Disable this rule if sibling imports are part of your module design.

Package documentationโ€‹

Rule catalog ID: R041

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.