exportFromImports
Reports imports that are re-exported and could use export...from syntax instead.
✅ This rule is included in the tsstylisticandstylisticStrictpresets.
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.
Examples
Section titled “Examples”Re-exporting Default Export
Section titled “Re-exporting Default Export”import import defaultExport
defaultExport from "./foo.js";export default import defaultExport
defaultExport;export { export default
default } from "./foo.js";Re-exporting Named Export
Section titled “Re-exporting Named Export”import { import named
named } from "./foo.js";export { export named
named };export { export named
named } from "./foo.js";Re-exporting Namespace
Section titled “Re-exporting Namespace”import * as import namespace
namespace from "./foo.js";export { export namespace
namespace };export * as import namespace
namespace from "./foo.js";Multiple Re-exports
Section titled “Multiple Re-exports”import import defaultExport
defaultExport, { import named
named } from "./foo.js";export default import defaultExport
defaultExport;export { import defaultExport
defaultExport as export renamedDefault
renamedDefault, export named
named, import named
named as export renamedNamed
renamedNamed };export { export default
default, any
default as export renamedDefault
renamedDefault, export named
named, any
named as export renamedNamed
renamedNamed,} from "./foo.js";Error ts(2307) ― Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you prefer the explicit import/export pattern for clarity in your codebase, this rule may not be for you.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noExportedImports - ESLint:
unicorn/prefer-export-from
Made with ❤️🔥 around the world by
the Flint team and contributors.