Skip to content

exportFromImports

Reports imports that are re-exported and could use export...from syntax instead.

✅ This rule is included in the ts stylistic and stylisticStrict presets.

When re-exporting from a module without otherwise using the imported value, it’s unnecessary to import and then export. It can be done in a single export...from declaration, which is more concise and makes the re-export intent clearer.

import defaultExport from "./foo.js";
export default defaultExport;
import { named } from "./foo.js";
export { named };
import * as namespace from "./foo.js";
export { namespace };
import defaultExport, { named } from "./foo.js";
export default defaultExport;
export { defaultExport as renamedDefault, named, named as renamedNamed };

This rule is not configurable.

If you prefer the explicit import/export pattern for clarity in your codebase, this rule may not be for you.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.