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.