-
-
Notifications
You must be signed in to change notification settings - Fork 420
Open
Labels
Description
Description
A repo can contain many submodules, they should only share code via the entries, but not import internal files directly.
This rule should require a configuration step, it should look like
{
'unicorn/this-rule-name': [
'error',
[
{
module: "a-module", // path to the module directory
entries: [
"index.js",
"another-private-entry.js",
],
message: "Please import functionality from `index.js` or `another-private-entry.js`"
},
// ... another submodule
]
]
}
Examples
// ❌
import {functionality} from "../a-module/internal-functionality.js"
// ✅
import {functionality} from "../a-module/index.js"Proposed rule name
no-submodule-import
Additional Info
This is just the basic idea, open for discussion.
We should only support module with ./ or ../, we don't want to dive into the module resolution hell.