Skip to main content

no-internal-modules

Disallow importing nested internal module paths.

Targeted pattern scope

This rule matches import/export sources that look like deep/internal module paths, using these default disallow globs:

  • ./*/**
  • [^@]*/**
  • @?*/*/**

What this rule reports

This rule reports imports/exports that target internal module segments such as:

  • ./folder/internal
  • package/internal
  • @scope/package/internal

It allows top-level entry imports such as ./folder, package, and @scope/package.

Why this rule exists

It enforces package entrypoint usage instead of importing deep internal files.

❌ Incorrect

import a from "./folder/internal";
import b from "package/internal";
import c from "@scope/package/internal";

✅ Correct

import a from "./folder";
import b from "package";
import c from "@scope/package";

Behavior and migration notes

This rule reports only and does not provide an autofix.

Use allow to carve out explicit exceptions while migrating toward public entrypoint imports.

Options

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

Default:

{
"disallow": ["./*/**", "[^@]*/**", "@?*/*/**"]
}

Additional examples

// default disallow includes "@?*/*/**"
import c from "@scope/package/internal/file";
// ❌ reported

import c from "@scope/package";
// ✅ valid

ESLint flat config example

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

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

When not to use it

Disable this rule if your project intentionally imports deep internal module paths.

Package documentation

Rule catalog ID: R029

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.