From dd8158029a4e6c282b19fe48f1f6fadfdd751bb8 Mon Sep 17 00:00:00 2001 From: Sander Verweij Date: Thu, 12 Dec 2024 09:26:17 +0100 Subject: [PATCH] feat: enables matching transitive dependencies in 'required' rules (#975) ## Description - [x] adds the `reachable` attribute to the 'required' rules schema - [x] adds reachable detection to the enrich step - [x] processes `reachable` in validating against 'required' rules - [x] update the documentation ## Motivation and Context See #973 ## How Has This Been Tested? - [x] green ci - [x] additional automated non-regression tests ## Example usage ```javascript /** @type {import('dependency-cruiser').IConfiguration} */ export default { required: [ { name: "must-reach-meta-cjs", comment: "all modules much reach, somehow, meta.cjs", module: { path: "^src/", }, to: { path: "^src/meta[.]cjs$", reachable: true, } } ], options: { // ... } } ``` ## 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) --- doc/rules-reference.md | 39 +++++- src/enrich/derive/reachable.mjs | 26 +++- src/schema/configuration.schema.json | 4 + src/schema/configuration.schema.mjs | 2 +- src/schema/cruise-result.schema.json | 4 + src/schema/cruise-result.schema.mjs | 2 +- src/validate/violates-required-rule.mjs | 18 ++- test/enrich/derive/reachable.spec.mjs | 88 +++++++++++- test/validate/index.required-rules.spec.mjs | 143 +++++++++++++++++++- tools/schema/restrictions.mjs | 5 + types/restrictions.d.mts | 4 + 11 files changed, 317 insertions(+), 18 deletions(-) diff --git a/doc/rules-reference.md b/doc/rules-reference.md index 8263cb843..58052b19a 100644 --- a/doc/rules-reference.md +++ b/doc/rules-reference.md @@ -93,6 +93,9 @@ controller _must depend on_ the base controller'. modules the rule applies to and the `to` describes what dependencies that module should exactly have. +To check for _direct_ dependencies (controllers must directly depend on the +base controller): + ```javascript { required: [ @@ -102,18 +105,48 @@ should exactly have. "Each controller should inherit from the framework's base controller", module: { // every module that matches the pattern specified in path & pathNot ... - path: "-controller\\.js$", - pathNot: "framework/base-controller\\.js$", + path: "-controller[.]js$", + pathNot: "framework/base-controller[.]js$", + }, + to: { + // ... must depend at least once on the framework's base controller + path: "^src/framework/base-controller[.]js$", + }, + }, + ]; +} +``` + +To check for _indirect_ ('transitive') dependencies (controllers must depend +on the base controller, either directly or via other modules) add the `reachable` +attribute to `to` part of the rule, like so: + +```javascript +{ + required: [ + { + name: "controllers-transitively-inherit-from-base", + comment: + "Each controller should inherit from the framework's base controller", + module: { + // every module that matches the pattern specified in path & pathNot ... + path: "-controller[.]js$", + pathNot: "framework/base-controller[.]js$", }, to: { // ... must depend at least once on the framework's base controller - path: "^src/framework/base-controller\\.js$", + path: "^src/framework/base-controller[.]js$", + // ... either directly or indirectly + reachable: true, }, }, ]; } ``` +> `reachable: false` is the same as leaving the reachable attribute out; so it +> does 'nothing'. + ### `extends` This takes one or more file path to other dependency-cruiser-configs. When diff --git a/src/enrich/derive/reachable.mjs b/src/enrich/derive/reachable.mjs index d6d0b2eb0..e3a27d6f1 100644 --- a/src/enrich/derive/reachable.mjs +++ b/src/enrich/derive/reachable.mjs @@ -13,18 +13,30 @@ function getReachableRules(pRuleSet) { (pRuleSet?.allowed ?? []).filter((pRule) => Object.hasOwn(pRule?.to ?? {}, "reachable"), ), + ) + .concat( + (pRuleSet?.required ?? []).filter((pRule) => + Object.hasOwn(pRule?.to ?? {}, "reachable"), + ), ); } function isModuleInRuleFrom(pRule) { - return (pModule) => - (!pRule.from.path || pModule.source.match(pRule.from.path)) && - (!pRule.from.pathNot || !pModule.source.match(pRule.from.pathNot)); + return (pModule) => { + const lRuleFrom = pRule.from ?? pRule.module; + if (lRuleFrom) { + return ( + (!lRuleFrom.path || pModule.source.match(lRuleFrom.path)) && + (!lRuleFrom.pathNot || !pModule.source.match(lRuleFrom.pathNot)) + ); + } + return false; + }; } function isModuleInRuleTo(pRule, pModuleTo, pModuleFrom) { const lGroups = pModuleFrom - ? extractGroups(pRule.from, pModuleFrom.source) + ? extractGroups(pRule.from ?? pRule.module, pModuleFrom.source) : []; return ( @@ -91,7 +103,11 @@ function hasCapturingGroups(pRule) { function shouldAddReachable(pRule, pModuleTo, pGraph) { let lReturnValue = false; - if (pRule.to.reachable === false || pRule.name === "not-in-allowed") { + if ( + pRule.to.reachable === false || + pRule.name === "not-in-allowed" || + pRule.module + ) { if (hasCapturingGroups(pRule)) { const lModulesFrom = pGraph.filter(isModuleInRuleFrom(pRule)); diff --git a/src/schema/configuration.schema.json b/src/schema/configuration.schema.json index a8e399d22..39d4b92cc 100644 --- a/src/schema/configuration.schema.json +++ b/src/schema/configuration.schema.json @@ -411,6 +411,10 @@ "path": { "description": "Criteria at least one dependency of each matching module must adhere to.", "$ref": "#/definitions/REAsStringsType" + }, + "reachable": { + "type": "boolean", + "description": "Whether or not to match transitive ('indirect') dependencies as well as direct ones." } } }, diff --git a/src/schema/configuration.schema.mjs b/src/schema/configuration.schema.mjs index 6c1948d19..c75100254 100644 --- a/src/schema/configuration.schema.mjs +++ b/src/schema/configuration.schema.mjs @@ -1 +1 @@ -/* generated - don't edit */export default{title:"dependency-cruiser configuration",$schema:"http://json-schema.org/draft-07/schema#",$id:"https://dependency-cruiser.js.org/schema/configuration.schema.json",type:"object",additionalProperties:false,properties:{$schema:{type:"string"},forbidden:{type:"array",items:{$ref:"#/definitions/ForbiddenRuleType"}},allowed:{type:"array",items:{$ref:"#/definitions/AllowedRuleType"}},allowedSeverity:{$ref:"#/definitions/SeverityType"},required:{type:"array",items:{$ref:"#/definitions/RequiredRuleType"}},options:{$ref:"#/definitions/OptionsType"},extends:{$ref:"#/definitions/ExtendsType"}},definitions:{RuleSetType:{type:"object",additionalProperties:false,properties:{forbidden:{type:"array",items:{$ref:"#/definitions/ForbiddenRuleType"}},allowed:{type:"array",items:{$ref:"#/definitions/AllowedRuleType"}},allowedSeverity:{$ref:"#/definitions/SeverityType"},required:{type:"array",items:{$ref:"#/definitions/RequiredRuleType"}}}},AllowedRuleType:{oneOf:[{$ref:"#/definitions/RegularAllowedRuleType"},{$ref:"#/definitions/ReachabilityAllowedRuleType"}]},RegularAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},ReachabilityAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},ForbiddenRuleType:{oneOf:[{$ref:"#/definitions/RegularForbiddenRuleType"},{$ref:"#/definitions/ReachabilityForbiddenRuleType"},{$ref:"#/definitions/DependentsForbiddenRuleType"}]},RegularForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},DependentsForbiddenRuleType:{type:"object",required:["module","from"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/DependentsModuleRestrictionType"},from:{$ref:"#/definitions/DependentsFromRestrictionType"}}},ReachabilityForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},RequiredRuleType:{type:"object",required:["module","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/RequiredModuleRestrictionType"},to:{$ref:"#/definitions/RequiredToRestrictionType"}}},MiniDependencyRestrictionType:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}}]},FromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},orphan:{type:"boolean"}}},ReachabilityFromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ToRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},couldNotResolve:{type:"boolean"},circular:{type:"boolean"},dynamic:{type:"boolean"},exoticallyRequired:{type:"boolean"},exoticRequire:{$ref:"#/definitions/REAsStringsType"},exoticRequireNot:{$ref:"#/definitions/REAsStringsType"},preCompilationOnly:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},moreThanOneDependencyType:{type:"boolean"},license:{$ref:"#/definitions/REAsStringsType"},licenseNot:{$ref:"#/definitions/REAsStringsType"},via:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaOnly:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},viaSomeNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},moreUnstable:{type:"boolean"}}},DependentsModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},numberOfDependentsLessThan:{type:"integer",minimum:0,maximum:100},numberOfDependentsMoreThan:{type:"integer",minimum:0,maximum:100}}},DependentsFromRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ReachabilityToRestrictionType:{required:["reachable"],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},reachable:{type:"boolean"}}},RequiredModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},RequiredToRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},DependencyTypeType:{type:"string",enum:["aliased-subpath-import","aliased-tsconfig-base-url","aliased-tsconfig-paths","aliased-tsconfig","aliased-webpack","aliased-workspace","aliased","amd-define","amd-require","amd-exotic-require","core","deprecated","dynamic-import","exotic-require","export","import-equals","import","jsdoc","jsdoc-bracket-import","jsdoc-import-tag","local","localmodule","npm-bundled","npm-dev","npm-no-pkg","npm-optional","npm-peer","npm-unknown","npm","pre-compilation-only","require","triple-slash-amd-dependency","triple-slash-directive","triple-slash-file-reference","triple-slash-type-reference","type-import","type-only","undetermined","unknown"]},REAsStringsType:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},SeverityType:{type:"string",enum:["error","warn","info","ignore"]},OptionsType:{type:"object",additionalProperties:false,properties:{doNotFollow:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundDoNotFollowType"}]},exclude:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundExcludeType"}]},includeOnly:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundIncludeOnlyType"}]},focus:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundFocusType"}]},reaches:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundReachesType"}]},affected:{oneOf:[{type:"string"},{type:"boolean"}]},highlight:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundHighlightType"}]},knownViolations:{$ref:"#/definitions/ViolationsType"},collapse:{oneOf:[{type:"string"},{type:"integer",minimum:1,maximum:9}]},maxDepth:{type:"integer",minimum:0,maximum:99},moduleSystems:{$ref:"#/definitions/ModuleSystemsType"},detectJSDocImports:{type:"boolean"},prefix:{type:"string"},preserveSymlinks:{type:"boolean"},combinedDependencies:{type:"boolean"},tsConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},tsPreCompilationDeps:{oneOf:[{type:"boolean"},{type:"string",enum:["specify"]}]},extraExtensionsToScan:{type:"array",items:{type:"string"}},externalModuleResolutionStrategy:{type:"string",enum:["node_modules","yarn-pnp"]},builtInModules:{type:"object",additionalProperties:false,properties:{override:{type:"array",items:{type:"string"}},add:{type:"array",items:{type:"string"}}}},forceDeriveDependents:{type:"boolean"},webpackConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"},env:{oneOf:[{type:"object"},{type:"string"}]},arguments:{type:"object"}}},enhancedResolveOptions:{type:"object",additionalProperties:false,properties:{exportsFields:{type:"array",items:{type:"string"}},conditionNames:{type:"array",items:{type:"string"}},extensions:{type:"array",items:{type:"string"}},mainFields:{type:"array",items:{type:"string"}},mainFiles:{type:"array"},aliasFields:{type:"array",items:{type:"string"}},cachedInputFileSystem:{type:"object",additionalProperties:false,properties:{cacheDuration:{type:"integer",minimum:0,maximum:1800000}}}}},babelConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},parser:{type:"string",enum:["acorn","tsc","swc"]},exoticRequireStrings:{type:"array",items:{type:"string"}},reporterOptions:{$ref:"#/definitions/ReporterOptionsType"},progress:{type:"object",additionalProperties:false,properties:{type:{type:"string",enum:["cli-feedback","performance-log","ndjson","none"]},maximumLevel:{type:"number",enum:[-1,40,50,60,70,80,99]}}},metrics:{type:"boolean"},experimentalStats:{type:"boolean"},baseDir:{type:"string"},cache:{oneOf:[{type:"boolean"},{deprecated:true,type:"string"},{$ref:"#/definitions/CacheOptionsType"}]}}},ModuleSystemType:{type:"string",enum:["cjs","es6","amd","tsd"]},ModuleSystemsType:{type:"array",items:{$ref:"#/definitions/ModuleSystemType"}},CompoundExcludeType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dynamic:{type:"boolean"}}},CompoundDoNotFollowType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},CompoundIncludeOnlyType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundFocusType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},depth:{type:"number",minimum:1,maximum:4}}},CompoundReachesType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundHighlightType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},ReporterOptionsType:{type:"object",additionalProperties:false,properties:{anon:{$ref:"#/definitions/AnonReporterOptionsType"},archi:{$ref:"#/definitions/DotReporterOptionsType"},dot:{$ref:"#/definitions/DotReporterOptionsType"},ddot:{$ref:"#/definitions/DotReporterOptionsType"},flat:{$ref:"#/definitions/DotReporterOptionsType"},markdown:{$ref:"#/definitions/MarkdownReporterOptionsType"},metrics:{$ref:"#/definitions/MetricsReporterOptionsType"},mermaid:{$ref:"#/definitions/MermaidReporterOptionsType"},text:{$ref:"#/definitions/TextReporterOptionsType"}}},AnonReporterOptionsType:{type:"object",additionalProperties:false,properties:{wordlist:{type:"array",items:{type:"string"}}}},MetricsReporterOptionsType:{type:"object",additionalProperties:false,properties:{orderBy:{type:"string",enum:["instability","moduleCount","afferentCouplings","efferentCouplings","name","size","topLevelStatementCount"]},hideModules:{type:"boolean"},hideFolders:{type:"boolean"}}},MarkdownReporterOptionsType:{type:"object",additionalProperties:false,properties:{showTitle:{type:"boolean"},title:{type:"string"},showSummary:{type:"boolean"},showSummaryHeader:{type:"boolean"},summaryHeader:{type:"string"},showStatsSummary:{type:"boolean"},showRulesSummary:{type:"boolean"},includeIgnoredInSummary:{type:"boolean"},showDetails:{type:"boolean"},includeIgnoredInDetails:{type:"boolean"},showDetailsHeader:{type:"boolean"},detailsHeader:{type:"string"},collapseDetails:{type:"boolean"},collapsedMessage:{type:"string"},noViolationsMessage:{type:"string"},showFooter:{type:"boolean"}}},MermaidReporterOptionsType:{type:"object",additionalProperties:false,properties:{minify:{type:"boolean"}}},TextReporterOptionsType:{type:"object",additionalProperties:false,properties:{highlightFocused:{type:"boolean"}}},DotReporterOptionsType:{type:"object",additionalProperties:false,properties:{collapsePattern:{$ref:"#/definitions/REAsStringsType"},filters:{$ref:"#/definitions/ReporterFiltersType"},showMetrics:{type:"boolean"},theme:{$ref:"#/definitions/DotThemeType"}}},DotThemeType:{type:"object",additionalProperties:false,properties:{replace:{type:"boolean"},graph:{type:"object"},node:{type:"object"},edge:{type:"object"},modules:{$ref:"#/definitions/DotThemeArrayType"},dependencies:{$ref:"#/definitions/DotThemeArrayType"}}},DotThemeArrayType:{type:"array",items:{$ref:"#/definitions/DotThemeEntryType"}},DotThemeEntryType:{type:"object",additionalProperties:false,properties:{criteria:{type:"object"},attributes:{type:"object"}}},ReporterFiltersType:{type:"object",additionalProperties:false,properties:{exclude:{$ref:"#/definitions/CompoundExcludeType"},includeOnly:{$ref:"#/definitions/CompoundIncludeOnlyType"},focus:{$ref:"#/definitions/CompoundFocusType"},reaches:{$ref:"#/definitions/CompoundReachesType"}}},ViolationsType:{type:"array",items:{$ref:"#/definitions/ViolationType"}},ViolationType:{type:"object",required:["from","to","rule"],additionalProperties:false,properties:{from:{type:"string"},to:{type:"string"},type:{$ref:"#/definitions/ViolationTypeType"},rule:{$ref:"#/definitions/RuleSummaryType"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},via:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},metrics:{type:"object",required:["from","to"],additionalProperties:false,properties:{from:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}},to:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}}}},comment:{type:"string"}}},RuleSummaryType:{type:"object",required:["name","severity"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"}}},ViolationTypeType:{type:"string",enum:["dependency","module","reachability","cycle","instability","folder"]},MiniDependency:{type:"object",required:["name","dependencyTypes"],additionalProperties:false,properties:{name:{type:"string"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},CacheOptionsType:{type:"object",additionalProperties:false,properties:{folder:{type:"string"},strategy:{$ref:"#/definitions/CacheStrategyType"},compress:{type:"boolean",default:false}}},CacheStrategyType:{type:"string",enum:["metadata","content"]},ExtendsType:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]}}}; \ No newline at end of file +/* generated - don't edit */export default{title:"dependency-cruiser configuration",$schema:"http://json-schema.org/draft-07/schema#",$id:"https://dependency-cruiser.js.org/schema/configuration.schema.json",type:"object",additionalProperties:false,properties:{$schema:{type:"string"},forbidden:{type:"array",items:{$ref:"#/definitions/ForbiddenRuleType"}},allowed:{type:"array",items:{$ref:"#/definitions/AllowedRuleType"}},allowedSeverity:{$ref:"#/definitions/SeverityType"},required:{type:"array",items:{$ref:"#/definitions/RequiredRuleType"}},options:{$ref:"#/definitions/OptionsType"},extends:{$ref:"#/definitions/ExtendsType"}},definitions:{RuleSetType:{type:"object",additionalProperties:false,properties:{forbidden:{type:"array",items:{$ref:"#/definitions/ForbiddenRuleType"}},allowed:{type:"array",items:{$ref:"#/definitions/AllowedRuleType"}},allowedSeverity:{$ref:"#/definitions/SeverityType"},required:{type:"array",items:{$ref:"#/definitions/RequiredRuleType"}}}},AllowedRuleType:{oneOf:[{$ref:"#/definitions/RegularAllowedRuleType"},{$ref:"#/definitions/ReachabilityAllowedRuleType"}]},RegularAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},ReachabilityAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},ForbiddenRuleType:{oneOf:[{$ref:"#/definitions/RegularForbiddenRuleType"},{$ref:"#/definitions/ReachabilityForbiddenRuleType"},{$ref:"#/definitions/DependentsForbiddenRuleType"}]},RegularForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},DependentsForbiddenRuleType:{type:"object",required:["module","from"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/DependentsModuleRestrictionType"},from:{$ref:"#/definitions/DependentsFromRestrictionType"}}},ReachabilityForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},RequiredRuleType:{type:"object",required:["module","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/RequiredModuleRestrictionType"},to:{$ref:"#/definitions/RequiredToRestrictionType"}}},MiniDependencyRestrictionType:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}}]},FromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},orphan:{type:"boolean"}}},ReachabilityFromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ToRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},couldNotResolve:{type:"boolean"},circular:{type:"boolean"},dynamic:{type:"boolean"},exoticallyRequired:{type:"boolean"},exoticRequire:{$ref:"#/definitions/REAsStringsType"},exoticRequireNot:{$ref:"#/definitions/REAsStringsType"},preCompilationOnly:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},moreThanOneDependencyType:{type:"boolean"},license:{$ref:"#/definitions/REAsStringsType"},licenseNot:{$ref:"#/definitions/REAsStringsType"},via:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaOnly:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},viaSomeNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},moreUnstable:{type:"boolean"}}},DependentsModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},numberOfDependentsLessThan:{type:"integer",minimum:0,maximum:100},numberOfDependentsMoreThan:{type:"integer",minimum:0,maximum:100}}},DependentsFromRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ReachabilityToRestrictionType:{required:["reachable"],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},reachable:{type:"boolean"}}},RequiredModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},RequiredToRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},reachable:{type:"boolean"}}},DependencyTypeType:{type:"string",enum:["aliased-subpath-import","aliased-tsconfig-base-url","aliased-tsconfig-paths","aliased-tsconfig","aliased-webpack","aliased-workspace","aliased","amd-define","amd-require","amd-exotic-require","core","deprecated","dynamic-import","exotic-require","export","import-equals","import","jsdoc","jsdoc-bracket-import","jsdoc-import-tag","local","localmodule","npm-bundled","npm-dev","npm-no-pkg","npm-optional","npm-peer","npm-unknown","npm","pre-compilation-only","require","triple-slash-amd-dependency","triple-slash-directive","triple-slash-file-reference","triple-slash-type-reference","type-import","type-only","undetermined","unknown"]},REAsStringsType:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},SeverityType:{type:"string",enum:["error","warn","info","ignore"]},OptionsType:{type:"object",additionalProperties:false,properties:{doNotFollow:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundDoNotFollowType"}]},exclude:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundExcludeType"}]},includeOnly:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundIncludeOnlyType"}]},focus:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundFocusType"}]},reaches:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundReachesType"}]},affected:{oneOf:[{type:"string"},{type:"boolean"}]},highlight:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundHighlightType"}]},knownViolations:{$ref:"#/definitions/ViolationsType"},collapse:{oneOf:[{type:"string"},{type:"integer",minimum:1,maximum:9}]},maxDepth:{type:"integer",minimum:0,maximum:99},moduleSystems:{$ref:"#/definitions/ModuleSystemsType"},detectJSDocImports:{type:"boolean"},prefix:{type:"string"},preserveSymlinks:{type:"boolean"},combinedDependencies:{type:"boolean"},tsConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},tsPreCompilationDeps:{oneOf:[{type:"boolean"},{type:"string",enum:["specify"]}]},extraExtensionsToScan:{type:"array",items:{type:"string"}},externalModuleResolutionStrategy:{type:"string",enum:["node_modules","yarn-pnp"]},builtInModules:{type:"object",additionalProperties:false,properties:{override:{type:"array",items:{type:"string"}},add:{type:"array",items:{type:"string"}}}},forceDeriveDependents:{type:"boolean"},webpackConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"},env:{oneOf:[{type:"object"},{type:"string"}]},arguments:{type:"object"}}},enhancedResolveOptions:{type:"object",additionalProperties:false,properties:{exportsFields:{type:"array",items:{type:"string"}},conditionNames:{type:"array",items:{type:"string"}},extensions:{type:"array",items:{type:"string"}},mainFields:{type:"array",items:{type:"string"}},mainFiles:{type:"array"},aliasFields:{type:"array",items:{type:"string"}},cachedInputFileSystem:{type:"object",additionalProperties:false,properties:{cacheDuration:{type:"integer",minimum:0,maximum:1800000}}}}},babelConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},parser:{type:"string",enum:["acorn","tsc","swc"]},exoticRequireStrings:{type:"array",items:{type:"string"}},reporterOptions:{$ref:"#/definitions/ReporterOptionsType"},progress:{type:"object",additionalProperties:false,properties:{type:{type:"string",enum:["cli-feedback","performance-log","ndjson","none"]},maximumLevel:{type:"number",enum:[-1,40,50,60,70,80,99]}}},metrics:{type:"boolean"},experimentalStats:{type:"boolean"},baseDir:{type:"string"},cache:{oneOf:[{type:"boolean"},{deprecated:true,type:"string"},{$ref:"#/definitions/CacheOptionsType"}]}}},ModuleSystemType:{type:"string",enum:["cjs","es6","amd","tsd"]},ModuleSystemsType:{type:"array",items:{$ref:"#/definitions/ModuleSystemType"}},CompoundExcludeType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dynamic:{type:"boolean"}}},CompoundDoNotFollowType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},CompoundIncludeOnlyType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundFocusType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},depth:{type:"number",minimum:1,maximum:4}}},CompoundReachesType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundHighlightType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},ReporterOptionsType:{type:"object",additionalProperties:false,properties:{anon:{$ref:"#/definitions/AnonReporterOptionsType"},archi:{$ref:"#/definitions/DotReporterOptionsType"},dot:{$ref:"#/definitions/DotReporterOptionsType"},ddot:{$ref:"#/definitions/DotReporterOptionsType"},flat:{$ref:"#/definitions/DotReporterOptionsType"},markdown:{$ref:"#/definitions/MarkdownReporterOptionsType"},metrics:{$ref:"#/definitions/MetricsReporterOptionsType"},mermaid:{$ref:"#/definitions/MermaidReporterOptionsType"},text:{$ref:"#/definitions/TextReporterOptionsType"}}},AnonReporterOptionsType:{type:"object",additionalProperties:false,properties:{wordlist:{type:"array",items:{type:"string"}}}},MetricsReporterOptionsType:{type:"object",additionalProperties:false,properties:{orderBy:{type:"string",enum:["instability","moduleCount","afferentCouplings","efferentCouplings","name","size","topLevelStatementCount"]},hideModules:{type:"boolean"},hideFolders:{type:"boolean"}}},MarkdownReporterOptionsType:{type:"object",additionalProperties:false,properties:{showTitle:{type:"boolean"},title:{type:"string"},showSummary:{type:"boolean"},showSummaryHeader:{type:"boolean"},summaryHeader:{type:"string"},showStatsSummary:{type:"boolean"},showRulesSummary:{type:"boolean"},includeIgnoredInSummary:{type:"boolean"},showDetails:{type:"boolean"},includeIgnoredInDetails:{type:"boolean"},showDetailsHeader:{type:"boolean"},detailsHeader:{type:"string"},collapseDetails:{type:"boolean"},collapsedMessage:{type:"string"},noViolationsMessage:{type:"string"},showFooter:{type:"boolean"}}},MermaidReporterOptionsType:{type:"object",additionalProperties:false,properties:{minify:{type:"boolean"}}},TextReporterOptionsType:{type:"object",additionalProperties:false,properties:{highlightFocused:{type:"boolean"}}},DotReporterOptionsType:{type:"object",additionalProperties:false,properties:{collapsePattern:{$ref:"#/definitions/REAsStringsType"},filters:{$ref:"#/definitions/ReporterFiltersType"},showMetrics:{type:"boolean"},theme:{$ref:"#/definitions/DotThemeType"}}},DotThemeType:{type:"object",additionalProperties:false,properties:{replace:{type:"boolean"},graph:{type:"object"},node:{type:"object"},edge:{type:"object"},modules:{$ref:"#/definitions/DotThemeArrayType"},dependencies:{$ref:"#/definitions/DotThemeArrayType"}}},DotThemeArrayType:{type:"array",items:{$ref:"#/definitions/DotThemeEntryType"}},DotThemeEntryType:{type:"object",additionalProperties:false,properties:{criteria:{type:"object"},attributes:{type:"object"}}},ReporterFiltersType:{type:"object",additionalProperties:false,properties:{exclude:{$ref:"#/definitions/CompoundExcludeType"},includeOnly:{$ref:"#/definitions/CompoundIncludeOnlyType"},focus:{$ref:"#/definitions/CompoundFocusType"},reaches:{$ref:"#/definitions/CompoundReachesType"}}},ViolationsType:{type:"array",items:{$ref:"#/definitions/ViolationType"}},ViolationType:{type:"object",required:["from","to","rule"],additionalProperties:false,properties:{from:{type:"string"},to:{type:"string"},type:{$ref:"#/definitions/ViolationTypeType"},rule:{$ref:"#/definitions/RuleSummaryType"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},via:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},metrics:{type:"object",required:["from","to"],additionalProperties:false,properties:{from:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}},to:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}}}},comment:{type:"string"}}},RuleSummaryType:{type:"object",required:["name","severity"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"}}},ViolationTypeType:{type:"string",enum:["dependency","module","reachability","cycle","instability","folder"]},MiniDependency:{type:"object",required:["name","dependencyTypes"],additionalProperties:false,properties:{name:{type:"string"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},CacheOptionsType:{type:"object",additionalProperties:false,properties:{folder:{type:"string"},strategy:{$ref:"#/definitions/CacheStrategyType"},compress:{type:"boolean",default:false}}},CacheStrategyType:{type:"string",enum:["metadata","content"]},ExtendsType:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]}}}; \ No newline at end of file diff --git a/src/schema/cruise-result.schema.json b/src/schema/cruise-result.schema.json index 0476eab22..0cc27c1e5 100644 --- a/src/schema/cruise-result.schema.json +++ b/src/schema/cruise-result.schema.json @@ -928,6 +928,10 @@ "path": { "description": "Criteria at least one dependency of each matching module must adhere to.", "$ref": "#/definitions/REAsStringsType" + }, + "reachable": { + "type": "boolean", + "description": "Whether or not to match transitive ('indirect') dependencies as well as direct ones." } } }, diff --git a/src/schema/cruise-result.schema.mjs b/src/schema/cruise-result.schema.mjs index 0ebdf2c52..32b907101 100644 --- a/src/schema/cruise-result.schema.mjs +++ b/src/schema/cruise-result.schema.mjs @@ -1 +1 @@ -/* generated - don't edit */export default{title:"dependency-cruiser output format",$schema:"http://json-schema.org/draft-07/schema#",$id:"https://dependency-cruiser.js.org/schema/cruise-result.schema.json",type:"object",required:["summary","modules"],additionalProperties:false,properties:{modules:{$ref:"#/definitions/ModulesType"},folders:{$ref:"#/definitions/FoldersType"},summary:{$ref:"#/definitions/SummaryType"},revisionData:{$ref:"#/definitions/RevisionDataType"}},definitions:{ModulesType:{type:"array",items:{$ref:"#/definitions/ModuleType"}},ModuleType:{type:"object",required:["source","dependencies","valid"],additionalProperties:false,properties:{source:{type:"string"},valid:{type:"boolean"},dependencies:{$ref:"#/definitions/DependenciesType"},dependents:{type:"array",items:{type:"string"}},followable:{type:"boolean"},matchesDoNotFollow:{type:"boolean"},matchesFocus:{type:"boolean"},matchesReaches:{type:"boolean"},matchesHighlight:{type:"boolean"},coreModule:{type:"boolean"},couldNotResolve:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},license:{type:"string"},orphan:{type:"boolean"},reachable:{type:"array",items:{$ref:"#/definitions/ReachableType"}},reaches:{type:"array",items:{$ref:"#/definitions/ReachesType"}},rules:{type:"array",items:{$ref:"#/definitions/RuleSummaryType"}},consolidated:{type:"boolean"},instability:{type:"number"},experimentalStats:{$ref:"#/definitions/ExperimentalStatsType"},checksum:{type:"string"}}},ReachableType:{type:"object",required:["value","asDefinedInRule","matchedFrom"],additionalProperties:false,properties:{value:{type:"boolean"},asDefinedInRule:{type:"string"},matchedFrom:{type:"string"}}},ReachesType:{type:"object",required:["modules","asDefinedInRule"],additionalProperties:false,properties:{modules:{type:"array",items:{type:"object",required:["source","via"],additionalProperties:false,properties:{source:{type:"string"},via:{type:"array",items:{$ref:"#/definitions/MiniDependency"}}}}},asDefinedInRule:{type:"string"}}},DependenciesType:{type:"array",items:{$ref:"#/definitions/DependencyType"}},DependencyType:{type:"object",required:["circular","coreModule","couldNotResolve","dependencyTypes","exoticallyRequired","dynamic","followable","module","moduleSystem","resolved","valid"],additionalProperties:false,properties:{module:{type:"string"},protocol:{type:"string",enum:["data:","file:","node:"]},mimeType:{type:"string"},resolved:{type:"string"},coreModule:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},license:{type:"string"},followable:{type:"boolean"},dynamic:{type:"boolean"},exoticallyRequired:{type:"boolean"},exoticRequire:{type:"string"},matchesDoNotFollow:{type:"boolean"},couldNotResolve:{type:"boolean"},preCompilationOnly:{type:"boolean"},typeOnly:{type:"boolean"},circular:{type:"boolean"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},moduleSystem:{$ref:"#/definitions/ModuleSystemType"},valid:{type:"boolean"},rules:{type:"array",items:{$ref:"#/definitions/RuleSummaryType"}},instability:{type:"number"}}},DependencyTypeType:{type:"string",enum:["aliased-subpath-import","aliased-tsconfig-base-url","aliased-tsconfig-paths","aliased-tsconfig","aliased-webpack","aliased-workspace","aliased","amd-define","amd-require","amd-exotic-require","core","deprecated","dynamic-import","exotic-require","export","import-equals","import","jsdoc","jsdoc-bracket-import","jsdoc-import-tag","local","localmodule","npm-bundled","npm-dev","npm-no-pkg","npm-optional","npm-peer","npm-unknown","npm","pre-compilation-only","require","triple-slash-amd-dependency","triple-slash-directive","triple-slash-file-reference","triple-slash-type-reference","type-import","type-only","undetermined","unknown"]},ModuleSystemType:{type:"string",enum:["cjs","es6","amd","tsd"]},RuleSummaryType:{type:"object",required:["name","severity"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"}}},SeverityType:{type:"string",enum:["error","warn","info","ignore"]},MiniDependency:{type:"object",required:["name","dependencyTypes"],additionalProperties:false,properties:{name:{type:"string"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},ExperimentalStatsType:{type:"object",required:["size","topLevelStatementCount"],additionalProperties:false,properties:{topLevelStatementCount:{type:"number"},size:{type:"number"}}},FoldersType:{type:"array",items:{$ref:"#/definitions/FolderType"}},FolderType:{type:"object",required:["name","moduleCount"],additionalProperties:false,properties:{name:{type:"string"},dependents:{type:"array",items:{type:"object",required:["name"],additionalProperties:false,properties:{name:{type:"string"}}}},dependencies:{type:"array",items:{type:"object",required:["name","valid","circular"],additionalProperties:false,properties:{name:{type:"string"},instability:{type:"number"},valid:{type:"boolean"},circular:{type:"boolean"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},rules:{type:"array",items:{$ref:"#/definitions/RuleSummaryType"}}}}},moduleCount:{type:"number"},afferentCouplings:{type:"number"},efferentCouplings:{type:"number"},instability:{type:"number"},experimentalStats:{$ref:"#/definitions/ExperimentalStatsType"}}},SummaryType:{type:"object",required:["violations","error","warn","info","totalCruised","optionsUsed"],additionalProperties:false,properties:{violations:{$ref:"#/definitions/ViolationsType"},error:{type:"number"},warn:{type:"number"},info:{type:"number"},ignore:{type:"number"},totalCruised:{type:"number"},totalDependenciesCruised:{type:"number"},ruleSetUsed:{$ref:"#/definitions/RuleSetType"},optionsUsed:{$ref:"#/definitions/OptionsUsedType"}}},ViolationsType:{type:"array",items:{$ref:"#/definitions/ViolationType"}},ViolationType:{type:"object",required:["from","to","rule"],additionalProperties:false,properties:{from:{type:"string"},to:{type:"string"},type:{$ref:"#/definitions/ViolationTypeType"},rule:{$ref:"#/definitions/RuleSummaryType"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},via:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},metrics:{type:"object",required:["from","to"],additionalProperties:false,properties:{from:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}},to:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}}}},comment:{type:"string"}}},ViolationTypeType:{type:"string",enum:["dependency","module","reachability","cycle","instability","folder"]},RuleSetType:{type:"object",additionalProperties:false,properties:{forbidden:{type:"array",items:{$ref:"#/definitions/ForbiddenRuleType"}},allowed:{type:"array",items:{$ref:"#/definitions/AllowedRuleType"}},allowedSeverity:{$ref:"#/definitions/SeverityType"},required:{type:"array",items:{$ref:"#/definitions/RequiredRuleType"}}}},AllowedRuleType:{oneOf:[{$ref:"#/definitions/RegularAllowedRuleType"},{$ref:"#/definitions/ReachabilityAllowedRuleType"}]},RegularAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},ReachabilityAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},ForbiddenRuleType:{oneOf:[{$ref:"#/definitions/RegularForbiddenRuleType"},{$ref:"#/definitions/ReachabilityForbiddenRuleType"},{$ref:"#/definitions/DependentsForbiddenRuleType"}]},RegularForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},DependentsForbiddenRuleType:{type:"object",required:["module","from"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/DependentsModuleRestrictionType"},from:{$ref:"#/definitions/DependentsFromRestrictionType"}}},ReachabilityForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},RequiredRuleType:{type:"object",required:["module","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/RequiredModuleRestrictionType"},to:{$ref:"#/definitions/RequiredToRestrictionType"}}},MiniDependencyRestrictionType:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}}]},FromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},orphan:{type:"boolean"}}},ReachabilityFromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ToRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},couldNotResolve:{type:"boolean"},circular:{type:"boolean"},dynamic:{type:"boolean"},exoticallyRequired:{type:"boolean"},exoticRequire:{$ref:"#/definitions/REAsStringsType"},exoticRequireNot:{$ref:"#/definitions/REAsStringsType"},preCompilationOnly:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},moreThanOneDependencyType:{type:"boolean"},license:{$ref:"#/definitions/REAsStringsType"},licenseNot:{$ref:"#/definitions/REAsStringsType"},via:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaOnly:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},viaSomeNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},moreUnstable:{type:"boolean"}}},DependentsModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},numberOfDependentsLessThan:{type:"integer",minimum:0,maximum:100},numberOfDependentsMoreThan:{type:"integer",minimum:0,maximum:100}}},DependentsFromRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ReachabilityToRestrictionType:{required:["reachable"],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},reachable:{type:"boolean"}}},RequiredModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},RequiredToRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},REAsStringsType:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},OptionsUsedType:{type:"object",additionalProperties:false,properties:{doNotFollow:{$ref:"#/definitions/CompoundDoNotFollowType"},exclude:{$ref:"#/definitions/CompoundExcludeType"},includeOnly:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundIncludeOnlyType"}]},focus:{$ref:"#/definitions/CompoundFocusType"},reaches:{$ref:"#/definitions/CompoundReachesType"},affected:{oneOf:[{type:"string"},{type:"boolean"}]},highlight:{$ref:"#/definitions/CompoundHighlightType"},knownViolations:{$ref:"#/definitions/ViolationsType"},collapse:{type:"string"},maxDepth:{type:"integer",minimum:0,maximum:99},moduleSystems:{$ref:"#/definitions/ModuleSystemsType"},detectJSDocImports:{type:"boolean"},prefix:{type:"string"},preserveSymlinks:{type:"boolean"},combinedDependencies:{type:"boolean"},tsConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},tsPreCompilationDeps:{oneOf:[{type:"boolean"},{type:"string",enum:["specify"]}]},extraExtensionsToScan:{type:"array",items:{type:"string"}},externalModuleResolutionStrategy:{type:"string",enum:["node_modules","yarn-pnp"]},builtInModules:{type:"object",additionalProperties:false,properties:{override:{type:"array",items:{type:"string"}},add:{type:"array",items:{type:"string"}}}},forceDeriveDependents:{type:"boolean"},webpackConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"},env:{oneOf:[{type:"object"},{type:"string"}]},arguments:{type:"object"}}},enhancedResolveOptions:{type:"object",additionalProperties:false,properties:{exportsFields:{type:"array",items:{type:"string"}},conditionNames:{type:"array",items:{type:"string"}},extensions:{type:"array",items:{type:"string"}},mainFields:{type:"array",items:{type:"string"}},mainFiles:{type:"array"},aliasFields:{type:"array",items:{type:"string"}},cachedInputFileSystem:{type:"object",additionalProperties:false,properties:{cacheDuration:{type:"integer",minimum:0,maximum:1800000}}}}},babelConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},parser:{type:"string",enum:["acorn","tsc","swc"]},exoticRequireStrings:{type:"array",items:{type:"string"}},reporterOptions:{$ref:"#/definitions/ReporterOptionsType"},progress:{type:"object",additionalProperties:false,properties:{type:{type:"string",enum:["cli-feedback","performance-log","ndjson","none"]},maximumLevel:{type:"number",enum:[-1,40,50,60,70,80,99]}}},metrics:{type:"boolean"},experimentalStats:{type:"boolean"},baseDir:{type:"string"},cache:{oneOf:[{type:"boolean",enum:[false]},{$ref:"#/definitions/CacheOptionsType"}]},args:{type:"string"},rulesFile:{type:"string"},outputTo:{type:"string"},outputType:{$ref:"#/definitions/OutputType"}}},ModuleSystemsType:{type:"array",items:{$ref:"#/definitions/ModuleSystemType"}},OutputType:{oneOf:[{type:"string",enum:["json","html","dot","ddot","cdot","archi","fdot","flat","csv","err","err-long","err-html","teamcity","anon","text","metrics","markdown","mermaid","d2","null"]},{type:"string",pattern:"^plugin:[^:]+$"}]},CompoundExcludeType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dynamic:{type:"boolean"}}},CompoundDoNotFollowType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},CompoundIncludeOnlyType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundFocusType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},depth:{type:"number",minimum:1,maximum:4}}},CompoundReachesType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundHighlightType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},ReporterOptionsType:{type:"object",additionalProperties:false,properties:{anon:{$ref:"#/definitions/AnonReporterOptionsType"},archi:{$ref:"#/definitions/DotReporterOptionsType"},dot:{$ref:"#/definitions/DotReporterOptionsType"},ddot:{$ref:"#/definitions/DotReporterOptionsType"},flat:{$ref:"#/definitions/DotReporterOptionsType"},markdown:{$ref:"#/definitions/MarkdownReporterOptionsType"},metrics:{$ref:"#/definitions/MetricsReporterOptionsType"},mermaid:{$ref:"#/definitions/MermaidReporterOptionsType"},text:{$ref:"#/definitions/TextReporterOptionsType"}}},AnonReporterOptionsType:{type:"object",additionalProperties:false,properties:{wordlist:{type:"array",items:{type:"string"}}}},MetricsReporterOptionsType:{type:"object",additionalProperties:false,properties:{orderBy:{type:"string",enum:["instability","moduleCount","afferentCouplings","efferentCouplings","name","size","topLevelStatementCount"]},hideModules:{type:"boolean"},hideFolders:{type:"boolean"}}},MarkdownReporterOptionsType:{type:"object",additionalProperties:false,properties:{showTitle:{type:"boolean"},title:{type:"string"},showSummary:{type:"boolean"},showSummaryHeader:{type:"boolean"},summaryHeader:{type:"string"},showStatsSummary:{type:"boolean"},showRulesSummary:{type:"boolean"},includeIgnoredInSummary:{type:"boolean"},showDetails:{type:"boolean"},includeIgnoredInDetails:{type:"boolean"},showDetailsHeader:{type:"boolean"},detailsHeader:{type:"string"},collapseDetails:{type:"boolean"},collapsedMessage:{type:"string"},noViolationsMessage:{type:"string"},showFooter:{type:"boolean"}}},MermaidReporterOptionsType:{type:"object",additionalProperties:false,properties:{minify:{type:"boolean"}}},TextReporterOptionsType:{type:"object",additionalProperties:false,properties:{highlightFocused:{type:"boolean"}}},DotReporterOptionsType:{type:"object",additionalProperties:false,properties:{collapsePattern:{$ref:"#/definitions/REAsStringsType"},filters:{$ref:"#/definitions/ReporterFiltersType"},showMetrics:{type:"boolean"},theme:{$ref:"#/definitions/DotThemeType"}}},DotThemeType:{type:"object",additionalProperties:false,properties:{replace:{type:"boolean"},graph:{type:"object"},node:{type:"object"},edge:{type:"object"},modules:{$ref:"#/definitions/DotThemeArrayType"},dependencies:{$ref:"#/definitions/DotThemeArrayType"}}},DotThemeArrayType:{type:"array",items:{$ref:"#/definitions/DotThemeEntryType"}},DotThemeEntryType:{type:"object",additionalProperties:false,properties:{criteria:{type:"object"},attributes:{type:"object"}}},ReporterFiltersType:{type:"object",additionalProperties:false,properties:{exclude:{$ref:"#/definitions/CompoundExcludeType"},includeOnly:{$ref:"#/definitions/CompoundIncludeOnlyType"},focus:{$ref:"#/definitions/CompoundFocusType"},reaches:{$ref:"#/definitions/CompoundReachesType"}}},CacheOptionsType:{type:"object",additionalProperties:false,properties:{folder:{type:"string"},strategy:{$ref:"#/definitions/CacheStrategyType"},compress:{type:"boolean",default:false}}},CacheStrategyType:{type:"string",enum:["metadata","content"]},RevisionDataType:{type:"object",required:["SHA1","changes"],properties:{cacheFormatVersion:{type:"number"},SHA1:{type:"string"},changes:{type:"array",items:{type:"object",required:["name","type"],properties:{name:{type:"string"},type:{type:"string",enum:["added","copied","deleted","modified","renamed","type changed","unmerged","pairing broken","unknown","unmodified","untracked","ignored"]},oldName:{type:"string"},checksum:{type:"string"},args:{type:"array",items:{type:"string"}},rulesFile:{type:"string"}}}}}}}}; \ No newline at end of file +/* generated - don't edit */export default{title:"dependency-cruiser output format",$schema:"http://json-schema.org/draft-07/schema#",$id:"https://dependency-cruiser.js.org/schema/cruise-result.schema.json",type:"object",required:["summary","modules"],additionalProperties:false,properties:{modules:{$ref:"#/definitions/ModulesType"},folders:{$ref:"#/definitions/FoldersType"},summary:{$ref:"#/definitions/SummaryType"},revisionData:{$ref:"#/definitions/RevisionDataType"}},definitions:{ModulesType:{type:"array",items:{$ref:"#/definitions/ModuleType"}},ModuleType:{type:"object",required:["source","dependencies","valid"],additionalProperties:false,properties:{source:{type:"string"},valid:{type:"boolean"},dependencies:{$ref:"#/definitions/DependenciesType"},dependents:{type:"array",items:{type:"string"}},followable:{type:"boolean"},matchesDoNotFollow:{type:"boolean"},matchesFocus:{type:"boolean"},matchesReaches:{type:"boolean"},matchesHighlight:{type:"boolean"},coreModule:{type:"boolean"},couldNotResolve:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},license:{type:"string"},orphan:{type:"boolean"},reachable:{type:"array",items:{$ref:"#/definitions/ReachableType"}},reaches:{type:"array",items:{$ref:"#/definitions/ReachesType"}},rules:{type:"array",items:{$ref:"#/definitions/RuleSummaryType"}},consolidated:{type:"boolean"},instability:{type:"number"},experimentalStats:{$ref:"#/definitions/ExperimentalStatsType"},checksum:{type:"string"}}},ReachableType:{type:"object",required:["value","asDefinedInRule","matchedFrom"],additionalProperties:false,properties:{value:{type:"boolean"},asDefinedInRule:{type:"string"},matchedFrom:{type:"string"}}},ReachesType:{type:"object",required:["modules","asDefinedInRule"],additionalProperties:false,properties:{modules:{type:"array",items:{type:"object",required:["source","via"],additionalProperties:false,properties:{source:{type:"string"},via:{type:"array",items:{$ref:"#/definitions/MiniDependency"}}}}},asDefinedInRule:{type:"string"}}},DependenciesType:{type:"array",items:{$ref:"#/definitions/DependencyType"}},DependencyType:{type:"object",required:["circular","coreModule","couldNotResolve","dependencyTypes","exoticallyRequired","dynamic","followable","module","moduleSystem","resolved","valid"],additionalProperties:false,properties:{module:{type:"string"},protocol:{type:"string",enum:["data:","file:","node:"]},mimeType:{type:"string"},resolved:{type:"string"},coreModule:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},license:{type:"string"},followable:{type:"boolean"},dynamic:{type:"boolean"},exoticallyRequired:{type:"boolean"},exoticRequire:{type:"string"},matchesDoNotFollow:{type:"boolean"},couldNotResolve:{type:"boolean"},preCompilationOnly:{type:"boolean"},typeOnly:{type:"boolean"},circular:{type:"boolean"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},moduleSystem:{$ref:"#/definitions/ModuleSystemType"},valid:{type:"boolean"},rules:{type:"array",items:{$ref:"#/definitions/RuleSummaryType"}},instability:{type:"number"}}},DependencyTypeType:{type:"string",enum:["aliased-subpath-import","aliased-tsconfig-base-url","aliased-tsconfig-paths","aliased-tsconfig","aliased-webpack","aliased-workspace","aliased","amd-define","amd-require","amd-exotic-require","core","deprecated","dynamic-import","exotic-require","export","import-equals","import","jsdoc","jsdoc-bracket-import","jsdoc-import-tag","local","localmodule","npm-bundled","npm-dev","npm-no-pkg","npm-optional","npm-peer","npm-unknown","npm","pre-compilation-only","require","triple-slash-amd-dependency","triple-slash-directive","triple-slash-file-reference","triple-slash-type-reference","type-import","type-only","undetermined","unknown"]},ModuleSystemType:{type:"string",enum:["cjs","es6","amd","tsd"]},RuleSummaryType:{type:"object",required:["name","severity"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"}}},SeverityType:{type:"string",enum:["error","warn","info","ignore"]},MiniDependency:{type:"object",required:["name","dependencyTypes"],additionalProperties:false,properties:{name:{type:"string"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},ExperimentalStatsType:{type:"object",required:["size","topLevelStatementCount"],additionalProperties:false,properties:{topLevelStatementCount:{type:"number"},size:{type:"number"}}},FoldersType:{type:"array",items:{$ref:"#/definitions/FolderType"}},FolderType:{type:"object",required:["name","moduleCount"],additionalProperties:false,properties:{name:{type:"string"},dependents:{type:"array",items:{type:"object",required:["name"],additionalProperties:false,properties:{name:{type:"string"}}}},dependencies:{type:"array",items:{type:"object",required:["name","valid","circular"],additionalProperties:false,properties:{name:{type:"string"},instability:{type:"number"},valid:{type:"boolean"},circular:{type:"boolean"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},rules:{type:"array",items:{$ref:"#/definitions/RuleSummaryType"}}}}},moduleCount:{type:"number"},afferentCouplings:{type:"number"},efferentCouplings:{type:"number"},instability:{type:"number"},experimentalStats:{$ref:"#/definitions/ExperimentalStatsType"}}},SummaryType:{type:"object",required:["violations","error","warn","info","totalCruised","optionsUsed"],additionalProperties:false,properties:{violations:{$ref:"#/definitions/ViolationsType"},error:{type:"number"},warn:{type:"number"},info:{type:"number"},ignore:{type:"number"},totalCruised:{type:"number"},totalDependenciesCruised:{type:"number"},ruleSetUsed:{$ref:"#/definitions/RuleSetType"},optionsUsed:{$ref:"#/definitions/OptionsUsedType"}}},ViolationsType:{type:"array",items:{$ref:"#/definitions/ViolationType"}},ViolationType:{type:"object",required:["from","to","rule"],additionalProperties:false,properties:{from:{type:"string"},to:{type:"string"},type:{$ref:"#/definitions/ViolationTypeType"},rule:{$ref:"#/definitions/RuleSummaryType"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},via:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},metrics:{type:"object",required:["from","to"],additionalProperties:false,properties:{from:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}},to:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}}}},comment:{type:"string"}}},ViolationTypeType:{type:"string",enum:["dependency","module","reachability","cycle","instability","folder"]},RuleSetType:{type:"object",additionalProperties:false,properties:{forbidden:{type:"array",items:{$ref:"#/definitions/ForbiddenRuleType"}},allowed:{type:"array",items:{$ref:"#/definitions/AllowedRuleType"}},allowedSeverity:{$ref:"#/definitions/SeverityType"},required:{type:"array",items:{$ref:"#/definitions/RequiredRuleType"}}}},AllowedRuleType:{oneOf:[{$ref:"#/definitions/RegularAllowedRuleType"},{$ref:"#/definitions/ReachabilityAllowedRuleType"}]},RegularAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},ReachabilityAllowedRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{comment:{type:"string"},scope:{type:"string",enum:["module","folder"]},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},ForbiddenRuleType:{oneOf:[{$ref:"#/definitions/RegularForbiddenRuleType"},{$ref:"#/definitions/ReachabilityForbiddenRuleType"},{$ref:"#/definitions/DependentsForbiddenRuleType"}]},RegularForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/FromRestrictionType"},to:{$ref:"#/definitions/ToRestrictionType"}}},DependentsForbiddenRuleType:{type:"object",required:["module","from"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/DependentsModuleRestrictionType"},from:{$ref:"#/definitions/DependentsFromRestrictionType"}}},ReachabilityForbiddenRuleType:{type:"object",required:["from","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},from:{$ref:"#/definitions/ReachabilityFromRestrictionType"},to:{$ref:"#/definitions/ReachabilityToRestrictionType"}}},RequiredRuleType:{type:"object",required:["module","to"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"},scope:{type:"string",enum:["module","folder"]},comment:{type:"string"},module:{$ref:"#/definitions/RequiredModuleRestrictionType"},to:{$ref:"#/definitions/RequiredToRestrictionType"}}},MiniDependencyRestrictionType:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}}]},FromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},orphan:{type:"boolean"}}},ReachabilityFromRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ToRestrictionType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},couldNotResolve:{type:"boolean"},circular:{type:"boolean"},dynamic:{type:"boolean"},exoticallyRequired:{type:"boolean"},exoticRequire:{$ref:"#/definitions/REAsStringsType"},exoticRequireNot:{$ref:"#/definitions/REAsStringsType"},preCompilationOnly:{type:"boolean"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},dependencyTypesNot:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}},moreThanOneDependencyType:{type:"boolean"},license:{$ref:"#/definitions/REAsStringsType"},licenseNot:{$ref:"#/definitions/REAsStringsType"},via:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaOnly:{$ref:"#/definitions/MiniDependencyRestrictionType"},viaNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},viaSomeNot:{deprecated:true,$ref:"#/definitions/REAsStringsType"},moreUnstable:{type:"boolean"}}},DependentsModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},numberOfDependentsLessThan:{type:"integer",minimum:0,maximum:100},numberOfDependentsMoreThan:{type:"integer",minimum:0,maximum:100}}},DependentsFromRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},ReachabilityToRestrictionType:{required:["reachable"],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"},reachable:{type:"boolean"}}},RequiredModuleRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},pathNot:{$ref:"#/definitions/REAsStringsType"}}},RequiredToRestrictionType:{required:[],type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},reachable:{type:"boolean"}}},REAsStringsType:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},OptionsUsedType:{type:"object",additionalProperties:false,properties:{doNotFollow:{$ref:"#/definitions/CompoundDoNotFollowType"},exclude:{$ref:"#/definitions/CompoundExcludeType"},includeOnly:{oneOf:[{$ref:"#/definitions/REAsStringsType"},{$ref:"#/definitions/CompoundIncludeOnlyType"}]},focus:{$ref:"#/definitions/CompoundFocusType"},reaches:{$ref:"#/definitions/CompoundReachesType"},affected:{oneOf:[{type:"string"},{type:"boolean"}]},highlight:{$ref:"#/definitions/CompoundHighlightType"},knownViolations:{$ref:"#/definitions/ViolationsType"},collapse:{type:"string"},maxDepth:{type:"integer",minimum:0,maximum:99},moduleSystems:{$ref:"#/definitions/ModuleSystemsType"},detectJSDocImports:{type:"boolean"},prefix:{type:"string"},preserveSymlinks:{type:"boolean"},combinedDependencies:{type:"boolean"},tsConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},tsPreCompilationDeps:{oneOf:[{type:"boolean"},{type:"string",enum:["specify"]}]},extraExtensionsToScan:{type:"array",items:{type:"string"}},externalModuleResolutionStrategy:{type:"string",enum:["node_modules","yarn-pnp"]},builtInModules:{type:"object",additionalProperties:false,properties:{override:{type:"array",items:{type:"string"}},add:{type:"array",items:{type:"string"}}}},forceDeriveDependents:{type:"boolean"},webpackConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"},env:{oneOf:[{type:"object"},{type:"string"}]},arguments:{type:"object"}}},enhancedResolveOptions:{type:"object",additionalProperties:false,properties:{exportsFields:{type:"array",items:{type:"string"}},conditionNames:{type:"array",items:{type:"string"}},extensions:{type:"array",items:{type:"string"}},mainFields:{type:"array",items:{type:"string"}},mainFiles:{type:"array"},aliasFields:{type:"array",items:{type:"string"}},cachedInputFileSystem:{type:"object",additionalProperties:false,properties:{cacheDuration:{type:"integer",minimum:0,maximum:1800000}}}}},babelConfig:{type:"object",additionalProperties:false,properties:{fileName:{type:"string"}}},parser:{type:"string",enum:["acorn","tsc","swc"]},exoticRequireStrings:{type:"array",items:{type:"string"}},reporterOptions:{$ref:"#/definitions/ReporterOptionsType"},progress:{type:"object",additionalProperties:false,properties:{type:{type:"string",enum:["cli-feedback","performance-log","ndjson","none"]},maximumLevel:{type:"number",enum:[-1,40,50,60,70,80,99]}}},metrics:{type:"boolean"},experimentalStats:{type:"boolean"},baseDir:{type:"string"},cache:{oneOf:[{type:"boolean",enum:[false]},{$ref:"#/definitions/CacheOptionsType"}]},args:{type:"string"},rulesFile:{type:"string"},outputTo:{type:"string"},outputType:{$ref:"#/definitions/OutputType"}}},ModuleSystemsType:{type:"array",items:{$ref:"#/definitions/ModuleSystemType"}},OutputType:{oneOf:[{type:"string",enum:["json","html","dot","ddot","cdot","archi","fdot","flat","csv","err","err-long","err-html","teamcity","anon","text","metrics","markdown","mermaid","d2","null"]},{type:"string",pattern:"^plugin:[^:]+$"}]},CompoundExcludeType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dynamic:{type:"boolean"}}},CompoundDoNotFollowType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},CompoundIncludeOnlyType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundFocusType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"},depth:{type:"number",minimum:1,maximum:4}}},CompoundReachesType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},CompoundHighlightType:{type:"object",additionalProperties:false,properties:{path:{$ref:"#/definitions/REAsStringsType"}}},ReporterOptionsType:{type:"object",additionalProperties:false,properties:{anon:{$ref:"#/definitions/AnonReporterOptionsType"},archi:{$ref:"#/definitions/DotReporterOptionsType"},dot:{$ref:"#/definitions/DotReporterOptionsType"},ddot:{$ref:"#/definitions/DotReporterOptionsType"},flat:{$ref:"#/definitions/DotReporterOptionsType"},markdown:{$ref:"#/definitions/MarkdownReporterOptionsType"},metrics:{$ref:"#/definitions/MetricsReporterOptionsType"},mermaid:{$ref:"#/definitions/MermaidReporterOptionsType"},text:{$ref:"#/definitions/TextReporterOptionsType"}}},AnonReporterOptionsType:{type:"object",additionalProperties:false,properties:{wordlist:{type:"array",items:{type:"string"}}}},MetricsReporterOptionsType:{type:"object",additionalProperties:false,properties:{orderBy:{type:"string",enum:["instability","moduleCount","afferentCouplings","efferentCouplings","name","size","topLevelStatementCount"]},hideModules:{type:"boolean"},hideFolders:{type:"boolean"}}},MarkdownReporterOptionsType:{type:"object",additionalProperties:false,properties:{showTitle:{type:"boolean"},title:{type:"string"},showSummary:{type:"boolean"},showSummaryHeader:{type:"boolean"},summaryHeader:{type:"string"},showStatsSummary:{type:"boolean"},showRulesSummary:{type:"boolean"},includeIgnoredInSummary:{type:"boolean"},showDetails:{type:"boolean"},includeIgnoredInDetails:{type:"boolean"},showDetailsHeader:{type:"boolean"},detailsHeader:{type:"string"},collapseDetails:{type:"boolean"},collapsedMessage:{type:"string"},noViolationsMessage:{type:"string"},showFooter:{type:"boolean"}}},MermaidReporterOptionsType:{type:"object",additionalProperties:false,properties:{minify:{type:"boolean"}}},TextReporterOptionsType:{type:"object",additionalProperties:false,properties:{highlightFocused:{type:"boolean"}}},DotReporterOptionsType:{type:"object",additionalProperties:false,properties:{collapsePattern:{$ref:"#/definitions/REAsStringsType"},filters:{$ref:"#/definitions/ReporterFiltersType"},showMetrics:{type:"boolean"},theme:{$ref:"#/definitions/DotThemeType"}}},DotThemeType:{type:"object",additionalProperties:false,properties:{replace:{type:"boolean"},graph:{type:"object"},node:{type:"object"},edge:{type:"object"},modules:{$ref:"#/definitions/DotThemeArrayType"},dependencies:{$ref:"#/definitions/DotThemeArrayType"}}},DotThemeArrayType:{type:"array",items:{$ref:"#/definitions/DotThemeEntryType"}},DotThemeEntryType:{type:"object",additionalProperties:false,properties:{criteria:{type:"object"},attributes:{type:"object"}}},ReporterFiltersType:{type:"object",additionalProperties:false,properties:{exclude:{$ref:"#/definitions/CompoundExcludeType"},includeOnly:{$ref:"#/definitions/CompoundIncludeOnlyType"},focus:{$ref:"#/definitions/CompoundFocusType"},reaches:{$ref:"#/definitions/CompoundReachesType"}}},CacheOptionsType:{type:"object",additionalProperties:false,properties:{folder:{type:"string"},strategy:{$ref:"#/definitions/CacheStrategyType"},compress:{type:"boolean",default:false}}},CacheStrategyType:{type:"string",enum:["metadata","content"]},RevisionDataType:{type:"object",required:["SHA1","changes"],properties:{cacheFormatVersion:{type:"number"},SHA1:{type:"string"},changes:{type:"array",items:{type:"object",required:["name","type"],properties:{name:{type:"string"},type:{type:"string",enum:["added","copied","deleted","modified","renamed","type changed","unmerged","pairing broken","unknown","unmodified","untracked","ignored"]},oldName:{type:"string"},checksum:{type:"string"},args:{type:"array",items:{type:"string"}},rulesFile:{type:"string"}}}}}}}}; \ No newline at end of file diff --git a/src/validate/violates-required-rule.mjs b/src/validate/violates-required-rule.mjs index 6b7e683c0..71683e231 100644 --- a/src/validate/violates-required-rule.mjs +++ b/src/validate/violates-required-rule.mjs @@ -2,7 +2,9 @@ import { matchesToPath, matchesModulePath, matchesModulePathNot, + matchToModulePath, } from "./matchers.mjs"; +import { matchesReachesRule } from "./match-module-rule-helpers.mjs"; import { extractGroups } from "#utl/regex-util.mjs"; /** @@ -20,11 +22,19 @@ export default function violatesRequiredRule(pRule, pModule) { matchesModulePath(pRule, pModule) && matchesModulePathNot(pRule, pModule) ) { - const lGroups = extractGroups(pRule.module, pModule.source); + if (pRule.to.reachable) { + lReturnValue = !matchesReachesRule(pRule, pModule); + } - lReturnValue = !pModule.dependencies.some((pDependency) => - matchesToPath(pRule, pDependency, lGroups), - ); + if (lReturnValue || !pRule.to.reachable) { + const lGroups = extractGroups(pRule.module, pModule.source); + const lMatchesSelf = matchToModulePath(pRule, pModule, lGroups); + lReturnValue = + !lMatchesSelf && + !pModule.dependencies.some((pDependency) => + matchesToPath(pRule, pDependency, lGroups), + ); + } } return lReturnValue; } diff --git a/test/enrich/derive/reachable.spec.mjs b/test/enrich/derive/reachable.spec.mjs index b36177c59..0322d9e30 100644 --- a/test/enrich/derive/reachable.spec.mjs +++ b/test/enrich/derive/reachable.spec.mjs @@ -114,7 +114,17 @@ describe("[U] enrich/derive/reachable/index - reachability detection", () => { deepEqual(addReachability(GRAPH, normalize({})), GRAPH); }); - it('returns the reachability annotated graph when a rule set with forbidden "reachable" in it', () => { + it("returns the input graph when passed a rule set with only a rul that doesn't have a 'from' or a 'module'", () => { + deepEqual( + addReachability( + GRAPH, + normalize({ required: [{ thing: {}, to: { reachable: true } }] }), + ), + GRAPH, + ); + }); + + it('returns the reachability annotated graph when a rule set with forbidden "reachable" in it (forbidden rule)', () => { const lForbiddenReachabilityRuleSetHajoo = { forbidden: [ { @@ -134,8 +144,8 @@ describe("[U] enrich/derive/reachable/index - reachability detection", () => { const lForbiddenReachabilityRuleSetHajoo = { allowed: [ { - from: { path: "src/[^.]+\\.js" }, - to: { path: "./src/hajoo\\.js$", reachable: true }, + from: { path: "src/[^.]+[.]js" }, + to: { path: "./src/hajoo[.]js$", reachable: true }, }, ], }; @@ -274,6 +284,78 @@ describe("[U] enrich/derive/reachable/index - reachability detection", () => { ); }); + it('returns the reachability annotated graph when a rule set with allowed "reachable" in it ("required" rules)', () => { + const lRequiredReachabilityRuleSetHajoo = { + required: [ + { + name: "must-reach-hajoo-somehow", + module: { path: "src/[^.]+[.]js" }, + to: { path: "./src/hajoo[.]js$", reachable: true }, + }, + ], + }; + const lExpected = [ + { + source: "./src/index.js", + dependencies: [ + { + resolved: "./src/intermediate.js", + }, + ], + reaches: [ + { + asDefinedInRule: "must-reach-hajoo-somehow", + modules: [ + { + source: "./src/hajoo.js", + via: [ + { name: "./src/intermediate.js", dependencyTypes: [] }, + { name: "./src/hajoo.js", dependencyTypes: [] }, + ], + }, + ], + }, + ], + }, + { + source: "./src/intermediate.js", + dependencies: [ + { + resolved: "./src/index.js", + }, + { + resolved: "./src/hajoo.js", + }, + ], + reaches: [ + { + asDefinedInRule: "must-reach-hajoo-somehow", + modules: [ + { + source: "./src/hajoo.js", + via: [{ name: "./src/hajoo.js", dependencyTypes: [] }], + }, + ], + }, + ], + }, + { + source: "./src/hajoo.js", + dependencies: [], + reachable: [ + { + value: true, + matchedFrom: "./src/index.js", + asDefinedInRule: "must-reach-hajoo-somehow", + }, + ], + }, + ]; + const lNormalizedGraph = normalize(lRequiredReachabilityRuleSetHajoo); + const lResult = addReachability(GRAPH, lNormalizedGraph); + deepEqual(lResult, lExpected); + }); + it('returns the reachability annotated graph when a rule set with allowed "reachable" in it (without a rule name - multiple matches)', () => { const lForbiddenReachabilityRuleSetHajoo = { allowed: [ diff --git a/test/validate/index.required-rules.spec.mjs b/test/validate/index.required-rules.spec.mjs index 4a5708e76..7eb40922b 100644 --- a/test/validate/index.required-rules.spec.mjs +++ b/test/validate/index.required-rules.spec.mjs @@ -2,7 +2,7 @@ import { deepEqual } from "node:assert/strict"; import parseRuleSet from "./parse-ruleset.utl.mjs"; import { validateDependency, validateModule } from "#validate/index.mjs"; -describe("[I] validate/index - required rules", () => { +describe("[I] validate/index - required rules - direct dependencies", () => { const lRequiredRuleSet = parseRuleSet({ required: [ { @@ -101,3 +101,144 @@ describe("[I] validate/index - required rules", () => { ); }); }); + +describe("[I] validate/index - required rules - transitive dependencies ('reachable')", () => { + const lRequiredRuleSet = parseRuleSet({ + required: [ + { + name: "thou-shalt-inherit-from-base", + module: { + path: ".+-controller[.]ts$", + pathNot: "random-trials", + }, + to: { + path: "src/base-controller/index[.]ts$", + reachable: true, + }, + }, + ], + }); + + it("modules not matching the module criteria from the required rule are okeliedokelie", () => { + deepEqual( + validateModule(lRequiredRuleSet, { + source: "something", + }), + { valid: true }, + ); + }); + + it("modules matching the module criteria with no dependencies bork", () => { + deepEqual( + validateModule(lRequiredRuleSet, { + source: "grub-controller.ts", + dependencies: [], + }), + { + rules: [{ name: "thou-shalt-inherit-from-base", severity: "warn" }], + valid: false, + }, + ); + }); + + it("modules matching the module criteria with no matching dependencies bork", () => { + deepEqual( + validateModule(lRequiredRuleSet, { + source: "grub-controller.ts", + dependencies: [ + { + resolved: "src/not-the-base-controller.ts", + }, + { + resolved: "src/not-the-base-controller-either.ts", + }, + ], + }), + { + rules: [{ name: "thou-shalt-inherit-from-base", severity: "warn" }], + valid: false, + }, + ); + }); + + it("modules that transitively depend on the required module are okeliedokelie", () => { + deepEqual( + validateModule(lRequiredRuleSet, { + source: "grub-controller.ts", + dependencies: [ + { + resolved: "src/not-the-base-controller.ts", + }, + { + resolved: "src/not-the-base-controller-either.ts", + }, + ], + reaches: [ + { + asDefinedInRule: "thou-shalt-inherit-from-base", + modules: [ + { + source: "src/base-controller/index.ts", + via: [ + { + name: "src/not-the-base-controller.ts", + dependencyTypes: ["local", "import"], + }, + ], + }, + ], + }, + ], + }), + { + valid: true, + }, + ); + }); + + it("the module itself doesn't get flagged as a transgression", () => { + const lRuleSet = parseRuleSet({ + required: [ + { + name: "do-depend-on-the-base-controller", + module: { + path: "src/", + }, + to: { + path: "src/base-controller/index[.]ts$", + reachable: true, + }, + }, + ], + }); + deepEqual( + validateModule(lRuleSet, { + source: "src/base-controller/index.ts", + dependencies: [], + reaches: [], + }), + { + valid: true, + }, + ); + }); + + it("'required' violations don't get flagged as dependency transgressions", () => { + deepEqual( + validateDependency(lRequiredRuleSet, { + source: "grub-controller.ts", + dependencies: [ + { + resolved: "src/not-the-base-controller.ts", + }, + { + resolved: "src/not-the-base-controller-either.ts", + }, + ], + }), + { + valid: true, + }, + ); + }); +}); diff --git a/tools/schema/restrictions.mjs b/tools/schema/restrictions.mjs index 27150941d..668152e56 100644 --- a/tools/schema/restrictions.mjs +++ b/tools/schema/restrictions.mjs @@ -303,6 +303,11 @@ export default { "adhere to.", $ref: "#/definitions/REAsStringsType", }, + reachable: { + type: "boolean", + description: + "Whether or not to match transitive ('indirect') dependencies as well as direct ones.", + }, }, }, ...dependencyType.definitions, diff --git a/types/restrictions.d.mts b/types/restrictions.d.mts index d8ac937ef..52d11ea6b 100644 --- a/types/restrictions.d.mts +++ b/types/restrictions.d.mts @@ -166,6 +166,10 @@ export interface IRequiredToRestrictionType { * one of the dependencies of the module should adhere to. */ path?: string | string[]; + /** + * Whether or not to match transitive ('indirect') dependencies as well as direct ones. + */ + reachable?: boolean; } export interface IDependentsModuleRestrictionType extends IBaseRestrictionType {