softarc-consulting / sheriff

Lightweight Modularity for TypeScript Projects
MIT License
188 stars 14 forks source link

Need help with depRules #125

Closed pdsavard closed 3 weeks ago

pdsavard commented 3 weeks ago

I am not sure to understand well how to applie rule. I got 2 domains that nned to be access anywhere (for now) from any tags. Shared and Shell. this is my config:

export const sheriffConfig: SheriffConfig = {
  excludeRoot: true,
  version: 1,
  tagging: {
    'src/app/@fuse/<fuse>': 'domain:fuse',
    'src/app/shell/<shell>': 'domain:shell',
    'src/app/domains/shared/<shared>': 'domain:shared',

    'src/app/domains/<domain>': {
      'feature-<feature>': ['domain:<domain>', 'type:feature'],
      'ui-<ui>': ['domain:<domain>', 'type:ui'],
      data: ['domain:<domain>', 'type:data'],
      '+store': ['domain:<domain>', 'type:data'],
      util: ['domain:<domain>', 'type:util'],
      routes: ['domain:<domain>', 'type:routes'],
    },
  },
  depRules: {
    root: ['domain:shell', 'domain:shared', anyTag],
    'domain:shell': [({ to }) => to.startsWith('domain'), 'type:feature', 'type:data', 'type:service'],
    'domain:*': ['domain:shared', 'domain:shell', anyTag],
    'type:feature': ['type:ui', 'type:data', 'type:util', 'type:animation', 'type:service'],
    'type:ui': ['type:data', 'type:util'],
    'type:data': ['type:util', 'type:data'],
    'type:util': ['type:data'],
  },
};

But I still get lint error like: 5:1 error module \src\app\domains\KelvinV2+store cannot access \src\app\domains\shared\utils. Tag type:data has no clearance for tags domain:shared @softarc/sheriff/dependency-rule 9:1 error module \src\app\domains\KelvinV2+store cannot access \src\app\shell\notification. Tag type:data has no clearance for tags domain:shell @softarc/sheriff/dependency-rule

rainerhahnekamp commented 3 weeks ago

Hi @pdsavard, yes, you are probably one of the developers who stumbled upon that fix in v0.17.0

Every from tag needs to have a clearance. In your case, the domain type is cleared but not the type one.

Can you update the following:

    'src/app/shell/<shell>': 'domain:shell',
    'src/app/domains/shared/<shared>': 'domain:shared',

to

    'src/app/shell/<shell>': ['domain:shell', 'type:shell'],
    'src/app/domains/shared/<shared>': ['domain:shared', 'type:shared'],

And also update your depRules accordingly. So if type:data needs to have access totype:shell and type:shared, it would be

'type:data': ['type:util', 'type:data', 'type:shell', 'type:shared']

Let me know, if that fixes the issue for you.