consistent-source-extension
Require consistent import/export source paths without file extensions.
Targeted pattern scopeโ
This rule reports string-literal module sources that end with these explicit extensions:
.js.json.ts
It applies to import/export sources and any matching source literal in supported module syntax nodes.
What this rule reportsโ
This rule reports import/export paths that end with .js, .json, or .ts.
Why this rule existsโ
Teams that standardize extensionless internal specifiers use this rule to keep import/export declarations consistent.
โ Incorrectโ
import x1 from "source.js";
import x2 from "source.json";
import x3 from "source.ts";
โ Correctโ
import x1 from "source";
import x2 from "source";
import x3 from "source";
Deprecatedโ
- Lifecycle: Deprecated and frozen.
- Deprecated since:
v1.0.0 - Available until:
v2.0.0 - Use instead:
import/extensions
Behavior and migration notesโ
This rule is deprecated in favor of import/extensions.
It reports only and does not provide an autofix.
Optionsโ
This rule has no options.
Statusโ
Use the Deprecated section above for lifecycle details.
Additional examplesโ
export * from "./utils.ts";
// โ reported
export * from "./utils";
// โ
valid
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/consistent-source-extension": "error",
},
},
];
When not to use itโ
Disable this rule if your module resolver requires explicit source file extensions.
Package documentationโ
Rule catalog ID: R009
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.