jraska/modules-graph-assert

[Help] Sublayer rules

marcellogalhardo opened this issue ยท 2 comments

I have the following configuration:

moduleGraphAssert {
    moduleLayers = [
            ":features:\\S*",
            ":libraries:\\S*",
    ]
    moduleLayersExclude = [
            ":libraries:\\S* -> :libraries:\\S*",
    ]
}

However, I have a use case where some features might be so big that will need to have submodules. Although, ideally we don't want different features to depend on each other. For example, hypothetically:

  • Valid: :features:sign_in:\\S* -> :features:sign_in:\\S*
  • Invalid: :features:sign_in:\\S* -> :features:sign_out:\\S*

For now I'm manually adding the feature names but this is problematic due to the number of exception rules we might need to have. Is there a way to do this in a generic way with current version of modules-graph-assert?

Hey, one option I see is using

moduleLayersExclude = [
            ":features:(\\S*):\\S* -> :features:\\1:\\S*", ...
    ]

To allow submodules dependencies.

Please let me know if that solves your problem :)

I did a quick test and it is working fine, thanks a lot! ๐Ÿ™