Skip to main content

No Re-Export Index Files

Avoid thin re-export/index files; put implementation in the main file

Source: .agents/rules/no-reexport-index-files.mdc

Metadata

  • globs: **/*.{ts,tsx}
  • alwaysApply: true

Content

No Re-Export Index Files

  • Do not create thin re-export files that only re-export from another location.
  • Put the implementation directly in the main component file (e.g. OptionsSideSheet.tsx, OptionCard.tsx).
  • Supporting files (types, constants, subcomponents) may live in subfolders, but the primary entry file should contain the actual logic.
// ❌ Avoid – thin re-export
// OptionCard/index.tsx
export { default } from './OptionCard';

// OptionsSideSheet.tsx
export { default } from './OptionsSideSheet/index';

// ✅ Prefer – implementation in main file
// OptionCard.tsx
const OptionCard: FC<OptionCardProps> = () => { /* ... */ };
export default OptionCard;

// OptionsSideSheet.tsx
const OptionsSideSheet: FC<OptionsSideSheetProps> = () => { /* ... */ };
export default OptionsSideSheet;