Our use case is to have some util classes/functions in a folder on top and then always import using relative path.
Eg.
src/
utils/
util1.js
comp1/
index.js
comp2/
index.js
From src/comp1/index.js i'd like to be able to import from ../utils/util1 but prohibit import from ../comp2
To achieve this, I see two options:
"import/no-relative-parent-imports": [ "error", { "allow": ["**/src/utils/**"] } ]
"import/no-internal-modules": [ "error", { "allow": ["**/src/utils/**"], "ignoreChildren": true } ]
I'm willing to provide a PR to any of the rules.
The former seems reasonable to me.
Any progress on this yet ?
I've been looking for exactly this (option 1).
There is already an option to do this with ignore regex
"import/no-relative-parent-imports": [
"error",
{
ignore: [".*/shared/.*"],
},
],
Most helpful comment
Any progress on this yet ?
I've been looking for exactly this (option 1).