no-index-import
Disallow importing directly from ".".
Targeted pattern scopeโ
This rule inspects module source strings and reports sources that are exactly
"." by default.
What this rule reportsโ
This rule reports import and export source strings that are exactly ".".
Why this rule existsโ
Bare "." imports often hide barrel/index dependencies and make module
relationships less explicit.
โ Incorrectโ
import value from ".";
export { value } from ".";
โ Correctโ
import value from "./feature";
export { value } from "./feature";
Behavior and migration notesโ
This rule reports only and does not provide an autofix.
Migration usually means replacing "." with a concrete relative path.
Optionsโ
type Options = {
allow?: string[];
disallow?: string[];
};
Default:
{
"disallow": ["."]
}
allow: glob patterns that are exempted.disallow: override default disallow patterns.
Additional examplesโ
const moduleRef = await import(".");
// โ reported
const moduleRef = await import("./feature");
// โ
valid
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-index-import": "error",
},
},
];
When not to use itโ
Disable this rule if your project intentionally uses "." barrel imports.
Package documentationโ
Rule catalog ID: R027
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.