Skip to content

feat: provide catch-all function to process dep rule#246

Merged
rainerhahnekamp merged 4 commits into
softarc-consulting:mainfrom
sdurnov:main
May 31, 2026
Merged

feat: provide catch-all function to process dep rule#246
rainerhahnekamp merged 4 commits into
softarc-consulting:mainfrom
sdurnov:main

Conversation

@sdurnov

@sdurnov sdurnov commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Here's a very drafty draft, mostly vibe coded.

rn I'm writing sheriff config for my project, and checking if it even works (seems to be working).

After I make sure, I can add few tests if necessary and fix any issues

#245

@sonarqubecloud

Copy link
Copy Markdown

@sdurnov sdurnov marked this pull request as ready for review March 27, 2026 15:39
@sdurnov

sdurnov commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

fixed stupid AI stuff and added some tests

@rainerhahnekamp rainerhahnekamp self-requested a review March 27, 2026 15:42
@rainerhahnekamp

Copy link
Copy Markdown
Collaborator

@sdurnov thanks. Plan to review it this week.

@sdurnov

sdurnov commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

@sdurnov thanks. Plan to review it this week.

Hi there, any quick thoughts on this maybe?

@rainerhahnekamp rainerhahnekamp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, just a few minor comments where I think an AI should be able to handle them properly 👍

Comment thread packages/core/package.json Outdated
Comment thread packages/core/src/lib/config/dependency-rules-config.ts Outdated
Comment thread packages/core/src/lib/config/dependency-rules-config.ts Outdated
Comment thread packages/core/src/lib/checks/tests/is-dependency-allowed.spec.ts Outdated
Comment thread packages/core/src/lib/checks/tests/is-dependency-allowed.spec.ts Outdated
Comment thread packages/core/src/lib/checks/tests/is-dependency-allowed.spec.ts Outdated
Comment thread packages/core/src/lib/checks/tests/is-dependency-allowed.spec.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

@sdurnov sdurnov requested a review from rainerhahnekamp April 30, 2026 14:46
@sdurnov

sdurnov commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

Hey, @rainerhahnekamp, hope it's fine now

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses #245 by exposing the resolved tag arrays of the source and target modules to function-based dependency rule matchers. With fromTags and toTags now available in DependencyCheckContext, users can implement cross-domain / multi-dimensional dependency rules with a single catch-all ('*') function rule.

Changes:

  • Add fromTags, toTags, from, and to directly to DependencyCheckContext and simplify RuleMatcherFn to receive only this context.
  • Populate the new tag fields when invoking isDependencyAllowed from checkForDependencyRuleViolation, and propagate from/to via spread inside isDependencyAllowed.
  • Add a createMockDependencyCheckContext helper and new tests demonstrating cross-domain rule patterns (shared domain, API exception, same-domain).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/lib/config/dependency-rules-config.ts Inlines from/to and adds fromTags/toTags into the DependencyCheckContext type; simplifies RuleMatcherFn.
packages/core/src/lib/checks/is-dependency-allowed.ts Spreads context first then overrides from/to when invoking the matcher function.
packages/core/src/lib/checks/check-for-dependency-rule-violation.ts Supplies the new fromTags/toTags (and placeholder from/to) to isDependencyAllowed.
packages/core/src/lib/checks/tests/is-dependency-allowed.spec.ts Introduces a context-mock factory and tests for cross-domain catch-all rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +5
from: string;
to: string;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, so from and to is only needed in isDependencyAllowed but not in checkForDependencyViolation?

If that's true, we should maybe keep RuleMatcherFn as the intersection type as it was and add fromTags, toTags to DependencyCheckContext.

I think tos in isDependencyAllowed is then also not necessary anymore.

@rainerhahnekamp rainerhahnekamp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdurnov, quickly yes or no:

Should I let Copilot finish this https://github.com/softarc-consulting/sheriff/pull/246/changes#r3255612945

Either way, you will be listed as the contributor

@rainerhahnekamp

Copy link
Copy Markdown
Collaborator

Closing this in favour of a new PR that incorporates the review feedback. Full credit to @sdurnov for the original implementation — the commits are preserved as-is in the new PR.

@sonarqubecloud

Copy link
Copy Markdown

@rainerhahnekamp rainerhahnekamp merged commit 0488bdc into softarc-consulting:main May 31, 2026
10 checks passed
@sdurnov

sdurnov commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Great, thanks!

@rainerhahnekamp

Copy link
Copy Markdown
Collaborator

Thank you and, we are doing a quick update of the project and then release the next version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants