Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(report/dot): adds ability to match arrays for conditional colori…
…ng (#882) ## Description - adds ability to match arrays for conditional coloring on the dot reporter's theming ## Motivation and Context So it's possible to add formatting based on array like properties (like `dependencyTypes`) and to have a convenient way to match against multiple criteria at the same time. ## How Has This Been Tested? - [x] green ci - [x] additional automated non-regression tests ## Screenshots E.g. to color based on types of aliased dependency types like this: ![colored-by-dependency-types](https://github.com/sverweij/dependency-cruiser/assets/4822597/3a11cb97-341d-41e4-8774-53331102cbf9) (from the reproduction example for #863 on https://github.com/sverweij/dependency-cruiser-repro-repo/tree/main/863) ... you can use this configuration that uses most features enabled by this PR: ```javascript /** @type {import('dependency-cruiser').IConfiguration} */ module.exports = { options: { doNotFollow: { path: "node_modules" }, moduleSystems: ["es6", "cjs"], tsPreCompilationDeps: true, combinedDependencies: true, tsConfig: { fileName: "tsconfig.json" }, reporterOptions: { dot: { theme: { graph: { rankdir: "TD", splines: "ortho", }, dependencies: [ { // if the dependency type is one of the tsconfig type aliases ... criteria: { dependencyTypes: [ "aliased-tsconfig-", "aliased-tsconfig-base-url", ], }, // ... color the line teal attributes: { color: "blue" }, }, { criteria: { dependencyTypes: ["aliased-workspace"] }, attributes: { color: "purple" }, }, { // if you just want one of the dependency types to match, a string suffices criteria: { dependencyTypes: "aliased-subpath-import" }, attributes: { color: "green" }, }, ], }, }, }, }, }; ``` ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Documentation only change - [ ] Refactor (non-breaking change which fixes an issue without changing functionality) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist - [x] 📖 - My change doesn't require a documentation update, or ... - it _does_ and I have updated it - [x] ⚖️ - The contribution will be subject to [The MIT license](https://github.com/sverweij/dependency-cruiser/blob/main/LICENSE), and I'm OK with that. - The contribution is my own original work. - I am ok with the stuff in [**CONTRIBUTING.md**](https://github.com/sverweij/dependency-cruiser/blob/main/.github/CONTRIBUTING.md).
- Loading branch information