Issue: depcruise doesn't fail if the path patterns in `from` or `to` are never matched

Author: JavaScriptBachCreated Jan 6, 2025Updated Jan 21, 2025
Labelsenhancement

Expected Behavior

If I write a reachability rule, and the paths defined in from or to don't resolve to actual files on disk, I've written an incorrect rule. It would be best if depcruise failed in this case so that the developer can catch and fix the rule. It also helps ensure that dependency tests continue to stay in sync as files are moved around.

Current Behavior

depcruise silently succeeds.

Possible Solution

Make depcruise fail if from or to are never matched by a file on disk.

Steps to Reproduce (for bugs)

I'm using 16.9.0-beta-1 and able to reproduce this with a simple rule of the form of

{
      from: {
        path: "path/that/doesnt/exist.ts",
      },
      to: {
        path: "path/that/exists.ts",
        reachable: true,
      },
    },

Context

I'm writing rules in depcruise, putting them in my CI, and I want them to continue to stay correct over time.

Your Environment

  • Version used: 16.9.0-beta-1
  • Node version: 20
  • Operating System and version: Ubuntu 22

Source: sverweij/dependency-cruiser