dependency-cruiser icon indicating copy to clipboard operation
dependency-cruiser copied to clipboard

Question: Restrict Imports Out of Directory Containing Config File

Open JRagone opened this issue 2 years ago • 2 comments

Summary

This is a little similar to #330, but I think it's more straightforward. Though I'm not much of a regex wizard, so I can't distinguish between this being impossible or just not clear to me.

I'd like to be able to restrict imports from going outside of the directory containing .dependency-cruiser.js. Say I have the following situation:

module
  |
   \
    submodule (containing .dependency-cruiser.js)

module depends on submodule, but nothing in submodule should depend on module or really anything outside submodule. It's no problem if submodule depends on children, grandchildren, etc.

Is there a way to accomplish this with regex?

Context

I'm working with some polyrepos. These repos are deployed as services. But some of these repos are submodules in other repos.

I'd like to prevent developers from importing outside the submodule, because the environment where the repo is used as a submodule doesn't match the repo's isolated deployment environment.

Environment

  • Version used: 11.11.0
  • Node version: 16.x
  • Operating System and version: macOS Monterey 12.11

JRagone avatar Jun 28 '22 19:06 JRagone

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Jul 06 '22 03:07 github-actions[bot]

I'll assume this isn't possible—I'm using monorepo-cop to meet this need for the moment.

JRagone avatar Jul 06 '22 04:07 JRagone