Skip to content
Esc

noctcore-architecture/index-must-reexport-default

A component folder’s index.ts must re-export the sibling default named after the folder.

When a component folder’s index.ts re-exports the component default, consumers import the folder (import Card from '@/components/Card') rather than reaching for the inner file (.../Card/Card). The barrel becomes the folder’s single public entry point, and the internal file layout stays free to change.

The rule only activates for an index.ts that sits next to a <Folder>.tsx of the same PascalCase name on disk (Card/Card.tsx beside Card/index.ts). For those barrels, it reports when the file never re-exports the sibling’s default export.

Card/index.ts
export { default as Card } from './Card'; // ✓
export { default } from './Card'; // ✓
export * from './Card.types'; // ✗ (on its own — no default re-export)
  • Non-component index.ts files — those whose folder is not PascalCase, or that have no <Folder>.tsx sibling on disk.
  • Files other than index.ts, such as Card/Card.helpers.ts.
  • A barrel that re-exports the default in either form, alongside any other re-exports.
  • Paths matched by allowIn.

This rule also reads the folder’s listing, so its result can change when that file does. eslint --cache does not notice and keeps the old result until the linted file itself changes. A long-running editor server picks up an edit to it, because the rule re-reads it when it changes. See Rules that read other files.

Option Type Default Meaning
allowIn string[] [] Globs (supporting **, *, ?) of paths to skip.
ignorePaths string[] (none) Deprecated alias of allowIn, kept through 1.x. When both are set, their globs are combined.
'noctcore-architecture/index-must-reexport-default': ['error', {
allowIn: ['**/ui/**'],
}]

If you do not use barrel files, or you export components as named (not default) exports, this rule does not apply.