Is there a lint rule to enforce export star from folders only?

Viewed 16

I have a published npm monorepo with 5 packages.

In each index file, I would like to enforce a convention where function and objects from the same folder are exported explicitly, whereas exports from any nested folder are exported with star (*). This way, I will avoid exposing things that I don't plan to the user of my package (while I still need to import them from within the same folder).

Each index.js will export everything from a nested folder, and by name from files in the same folder.

Example:

- app
  + index.js
  + foo
  | + index.js
  | + bar.js 
  | + nestedFolder
    | ...
// app/index.js

export * from './foo';
// app/foo/index.js

export { someFunction } from './bar';
export * from './nested-folder';

Is there an existing lint rule that can fit our needs?

0 Answers
Related