question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@nrwl/nx/enforce-module-boundaries allow AND/OR

See original GitHub issue

Description

Allow AND/OR usage with tags.

Motivation

Currently the behavior is OR only, having AND would enable many more combinations to be possible without introducing new tags.

Suggested Implementation

Not so much implementation but an example api

"depConstraints": [
  {
    "sourceTag": "layer:ui",
    "onlyDependOnLibsWithTags": [{
      "tags": ["scope:admin", "layer:backend"],
      "operation": "AND"
    }]
  },
]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
meeroslavcommented, Sep 22, 2021

You don’t need to introduce the new tag or have new operator. You can simply split it into two constraints. The following behaves as AND:

"depConstraints": [
  {
    "sourceTag": "layer:ui",
    "onlyDependOnLibsWithTags": ["scope:admin"]
  },
  {
    "sourceTag": "layer:ui",
    "onlyDependOnLibsWithTags": ["layer:backend"]
  },
]

It does look like a bit of overhead, but the benefit is it gives you granular control and an overview of how tags are connected. Let me know if this works for your use case.

Note: The following logic is not implemented The other variant I see could be (notice inner array acting as AND):

"depConstraints": [
  {
    "sourceTag": "layer:ui",
    "onlyDependOnLibsWithTags": [["these:are", "joined:with:and"], "this:one:joins:with:or"]
  },
]

But I’m not convinced this wouldn’t end up being the foot gun.

0reactions
meeroslavcommented, Oct 12, 2021

I used non-framework for simplicity. In real application, you would never use such tag name. You could use architecture:x or something in those lines. But I hope you got the idea - if you bring new dimension (support for framework in your case) to the equation you need to make sure all the projects have an opinion (tag) on how they want to handle it, otherwise your rules will ban them.

We usually use scope:x for focus (vertical) segmentation and type:x for horizontal segmentation (apps, ui-features, libs, utils etc.). Usually all projects within one scope use the same framework, so there is no need for an explicit framework tag.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enforce Project Boundaries - Nx
Project APIs​​ Nx provides an enforce-module-boundaries eslint rule that enforces the public API of projects in the repo. Each project defines its public...
Read more >
Taming Code Organization with Module Boundaries in Nx
Using common sense, we would like to enforce certain boundaries: A shared or core library should not be able to depend on a...
Read more >
Taming Code Organization with Module Boundaries in Nx
Zack DeRose is joined by Nrwlian Miroslav Jonas to talk about Taming Code Organization with Module Boundaries in Nx.Submit questions ...
Read more >
eslint rule @nrwl/nx/enforce-module-boundaries fails [UPDATE]
Probably a better solution​​ to the paths in compilerOptions of your tsconfig. base. json in the repo root. Then put "allowCircularSelfDependency ...
Read more >
nrwl-nx/community - Gitter
Hey guys, I enabled the rule "nx-enforce-module-boundaries". Now I am getting linting error because I do lazy loading of imports in one specific...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found