Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to use "scope: folder" for detecting circular imports between folders in a folder #762

Open
Aaronkala opened this issue Mar 22, 2023 · 2 comments
Labels

Comments

@Aaronkala
Copy link

Summary

We have features/libraries in a modules/ folder. We'd like to allow a acyclic dependency graph between the modules while guarding against circular dependencies.

If a file in modules/a/ depends on a file in modules/b/, nothing in modules/b/ can depend on modules/a/.

I noticed that there's a scope option. But I'm unsure how would I configure the rule and I'm looking for some examples.

Context

The following rule configuration leaks outside the /modules/ folder causing them to be included in the "circular" detection. Example error caused by this: /module/a -> /common/ -> /api/ -> /views/ -> /module/a.

{
  name: 'no-circular-dependency-between-modules',
  comment:
    'If a module A depends on module B, then ' +
    'module B should not depend on module A',
  severity: 'error',
  from: {
    path: '/modules/([^/]+)'
  },
  to: {
    circular: true,
  },
  scope: "folder",
},

What I'd love to get is some way to confine the scope to only circulars between the /module/ folders. The via examples look like they might provide a fix here, but I'm unsure if scope: "folder" supports via yet.

The full solution we are trying to implement is:

  1. Forbid acyclic imports between modules
  2. Forbid all imports between modules, unless explicitly allowed (a can import b)

Environment

  • Version used: latest
  • Node version: 18
@github-actions
Copy link

github-actions bot commented Apr 1, 2023

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 github-actions bot added the stale label Apr 1, 2023
@sverweij sverweij removed the stale label Apr 3, 2023
@github-actions
Copy link

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 github-actions bot added the stale label Apr 13, 2023
@sverweij sverweij added question and removed stale labels Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants