Folders public api in independent modules #37
-
Would be nice to have a a rule that folder should have a public api to access its files, for example: I want to import shared component, so i go Otherwise, I should import it like so: Maybe It would be easier to know what you should import and consider adding an For instance, I want to throw an error here - |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can achieve exactly the same effect by allowing the import of only the index.ts file, for example, like this: And separately, you can add rules for index.ts files so that they can import more. {
name: "Some module index file",
pattern: "src/someModule/**/index.ts",
allowImportsFrom: [
"{family}/**",
],
},
{
name: "Some module",
pattern: "src/someModule/**",
allowImportsFrom: [
"src/shared/*/index.ts",
"src/shared/**/index.ts",
"{family}/*/someFolder/index.ts",
"{family}/**/someFolder/index.ts",
// ... etc
],
}, |
Beta Was this translation helpful? Give feedback.
I don't understand, it will require imports only from index.ts, so theoretically, you have to create index.ts to import anything at all. If you want to enforce the existence of a file when a folder exists, you can use enforceExistence.