@archest/jest 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +162 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/matchers/index.d.ts +23 -0
  7. package/dist/matchers/models.d.ts +201 -0
  8. package/node_modules/@archest/core/dist/classes/classCheckExtendClass.d.ts +3 -0
  9. package/node_modules/@archest/core/dist/classes/classCheckHaveMaxCyclomaticComplexity.d.ts +3 -0
  10. package/node_modules/@archest/core/dist/classes/classCheckHaveModifier.d.ts +3 -0
  11. package/node_modules/@archest/core/dist/classes/classCheckHaveNameMatchingFileName.d.ts +3 -0
  12. package/node_modules/@archest/core/dist/classes/classCheckImplementInterface.d.ts +3 -0
  13. package/node_modules/@archest/core/dist/classes/classCheckMatchNamePattern.d.ts +3 -0
  14. package/node_modules/@archest/core/dist/classes/classCheckResideInFolder.d.ts +3 -0
  15. package/node_modules/@archest/core/dist/classes/locateClasses.d.ts +5 -0
  16. package/node_modules/@archest/core/dist/classes/types.d.ts +25 -0
  17. package/node_modules/@archest/core/dist/dto.d.ts +78 -0
  18. package/node_modules/@archest/core/dist/files/checkDependOnExternalModule.d.ts +3 -0
  19. package/node_modules/@archest/core/dist/files/checkDependOnFilesInFolder.d.ts +3 -0
  20. package/node_modules/@archest/core/dist/files/fileCheckBeFreeOfCycles.d.ts +3 -0
  21. package/node_modules/@archest/core/dist/files/fileCheckHaveMaxCyclomaticComplexity.d.ts +3 -0
  22. package/node_modules/@archest/core/dist/files/fileCheckHaveMaxExportedFunctions.d.ts +3 -0
  23. package/node_modules/@archest/core/dist/files/fileCheckHaveMinMaintainabilityIndex.d.ts +3 -0
  24. package/node_modules/@archest/core/dist/files/fileCheckMatchNamePattern.d.ts +3 -0
  25. package/node_modules/@archest/core/dist/files/getFileDependencies.d.ts +2 -0
  26. package/node_modules/@archest/core/dist/files/locateFiles.d.ts +4 -0
  27. package/node_modules/@archest/core/dist/files/types.d.ts +17 -0
  28. package/node_modules/@archest/core/dist/functions/functionCheckHaveExplicitReturnType.d.ts +3 -0
  29. package/node_modules/@archest/core/dist/functions/functionCheckHaveMaxCyclomaticComplexity.d.ts +3 -0
  30. package/node_modules/@archest/core/dist/functions/functionCheckHaveMinMaintainabilityIndex.d.ts +3 -0
  31. package/node_modules/@archest/core/dist/functions/functionCheckHaveModifier.d.ts +3 -0
  32. package/node_modules/@archest/core/dist/functions/functionCheckHaveNameMatchingFileName.d.ts +3 -0
  33. package/node_modules/@archest/core/dist/functions/functionCheckMatchNamePattern.d.ts +3 -0
  34. package/node_modules/@archest/core/dist/functions/locateFunctions.d.ts +5 -0
  35. package/node_modules/@archest/core/dist/functions/types.d.ts +19 -0
  36. package/node_modules/@archest/core/dist/index.d.ts +43 -0
  37. package/node_modules/@archest/core/dist/index.js +14 -0
  38. package/node_modules/@archest/core/dist/index.js.map +1 -0
  39. package/node_modules/@archest/core/dist/index.mjs +607 -0
  40. package/node_modules/@archest/core/dist/index.mjs.map +1 -0
  41. package/node_modules/@archest/core/dist/layers/checkLayeredArchitecture.d.ts +3 -0
  42. package/node_modules/@archest/core/dist/layers/createLayeredArchitecture.d.ts +3 -0
  43. package/node_modules/@archest/core/dist/layers/getLayerDependencies.d.ts +2 -0
  44. package/node_modules/@archest/core/dist/layers/layer.d.ts +2 -0
  45. package/node_modules/@archest/core/dist/layers/layerShouldNotBeAccessedByAnyLayer.d.ts +2 -0
  46. package/node_modules/@archest/core/dist/layers/layerShouldOnlyBeAccessedBy.d.ts +2 -0
  47. package/node_modules/@archest/core/dist/layers/types.d.ts +8 -0
  48. package/node_modules/@archest/core/dist/metrics/calculateCyclomaticComplexity.d.ts +2 -0
  49. package/node_modules/@archest/core/dist/metrics/calculateMaintainabilityIndex.d.ts +2 -0
  50. package/node_modules/@archest/core/dist/project/parseProject.d.ts +55 -0
  51. package/node_modules/@archest/core/dist/properties/locateProperties.d.ts +5 -0
  52. package/node_modules/@archest/core/dist/properties/propertyCheckBeReadonly.d.ts +3 -0
  53. package/node_modules/@archest/core/dist/properties/types.d.ts +17 -0
  54. package/node_modules/@archest/core/dist/shared/sharedCheckHaveMaxCyclomaticComplexity.d.ts +1 -0
  55. package/node_modules/@archest/core/dist/shared/sharedCheckHaveMinMaintainabilityIndex.d.ts +1 -0
  56. package/node_modules/@archest/core/dist/shared/sharedCheckHaveModifier.d.ts +7 -0
  57. package/node_modules/@archest/core/dist/shared/sharedCheckHaveNameMatchingFileName.d.ts +3 -0
  58. package/node_modules/@archest/core/dist/shared/sharedCheckMatchNamePattern.d.ts +1 -0
  59. package/node_modules/@archest/core/dist/slices/locateSlices.d.ts +3 -0
  60. package/node_modules/@archest/core/dist/slices/sliceCheckBeFreeOfCycles.d.ts +3 -0
  61. package/node_modules/@archest/core/dist/slices/sliceCheckHaveMaxDistanceFromMainSequence.d.ts +3 -0
  62. package/node_modules/@archest/core/dist/slices/types.d.ts +8 -0
  63. package/node_modules/@archest/core/dist/types.d.ts +11 -0
  64. package/node_modules/@archest/core/dist/utils/ruleBuilder.d.ts +6 -0
  65. package/node_modules/@archest/core/package.json +49 -0
  66. package/node_modules/@archest/core-rust/core-rust.darwin-arm64.node +0 -0
  67. package/node_modules/@archest/core-rust/index.d.ts +16 -0
  68. package/node_modules/@archest/core-rust/index.js +316 -0
  69. package/node_modules/@archest/core-rust/package.json +34 -0
  70. package/package.json +56 -0
@@ -0,0 +1,3 @@
1
+ export type { ClassData, ClassQueryOptions, FileData, FileQueryOptions, FunctionData, FunctionQueryOptions, ProjectData, PropertyData, PropertyQueryOptions, } from '@archest/core';
2
+ export { type ParseProjectOptions, parseProject, } from '@archest/core';
3
+ export { type ArchestMatchers, setupMatchers } from './matchers';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@archest/core`)):typeof define==`function`&&define.amd?define([`exports`,`@archest/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.JestArch={},e._archest_core))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(){expect.extend({toPass(e){let n;n=e?.data&&e.data.type===`LayeredArchitecture`?(0,t.checkLayeredArchitecture)(e.data):e;let{pass:r,message:i}=n;return{pass:this.isNot?!r:r,message:r?()=>`Expected rule not to pass`:()=>i()}},toResideInFolder(e,n){let r;if(e.type===`ClassLocator`)r=(0,t.classCheckResideInFolder)(e,n,!!this.isNot);else throw Error(`toResideInFolder matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toHaveModifier(e,n){let r;if(e.type===`ClassLocator`)r=(0,t.classCheckHaveModifier)(e,n,!!this.isNot);else if(e.type===`FunctionLocator`)r=(0,t.functionCheckHaveModifier)(e,n,!!this.isNot);else throw Error(`toHaveModifier matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toExtendClass(e,n){let r;if(e.type===`ClassLocator`)r=(0,t.classCheckExtendClass)(e,n,!!this.isNot);else throw Error(`toExtendClass matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toImplementInterface(e,n){let r;if(e.type===`ClassLocator`)r=(0,t.classCheckImplementInterface)(e,n,!!this.isNot);else throw Error(`toImplementInterface matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toHaveExplicitReturnType(e){let n;if(e.type===`FunctionLocator`)n=(0,t.functionCheckHaveExplicitReturnType)(e,!!this.isNot);else throw Error(`toHaveExplicitReturnType matcher does not support ${e.type}`);return{pass:this.isNot?!n.pass:n.pass,message:n.message}},toBeReadonly(e){let n;if(e.type===`PropertyLocator`)n=(0,t.propertyCheckBeReadonly)(e,!!this.isNot);else throw Error(`toBeReadonly matcher does not support ${e.type}`);return{pass:this.isNot?!n.pass:n.pass,message:n.message}},toDependOnFilesInFolder(e,n){let r;if(e.type===`FileLocator`)r=(0,t.checkDependOnFilesInFolder)(e,n,!!this.isNot);else throw Error(`toDependOnFilesInFolder matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toDependOnExternalModule(e,n){let r;if(e.type===`FileLocator`)r=(0,t.checkDependOnExternalModule)(e,n,!!this.isNot);else throw Error(`toDependOnExternalModule matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toBeFreeOfCycles(e){let n;if(e.type===`FileLocator`)n=(0,t.fileCheckBeFreeOfCycles)(e,!!this.isNot);else if(e.type===`SliceLocator`)n=(0,t.sliceCheckBeFreeOfCycles)(e,!!this.isNot);else throw Error(`toBeFreeOfCycles matcher does not support ${e.type}`);return{pass:this.isNot?!n.pass:n.pass,message:n.message}},toMatchNamePattern(e,n){let r;if(e.type===`FileLocator`)r=(0,t.fileCheckMatchNamePattern)(e,n,!!this.isNot);else if(e.type===`ClassLocator`)r=(0,t.classCheckMatchNamePattern)(e,n,!!this.isNot);else if(e.type===`FunctionLocator`)r=(0,t.functionCheckMatchNamePattern)(e,n,!!this.isNot);else throw Error(`toMatchNamePattern matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toHaveMaxCyclomaticComplexity(e,n){let r;if(e.type===`FileLocator`)r=(0,t.fileCheckHaveMaxCyclomaticComplexity)(e,n,!!this.isNot);else if(e.type===`ClassLocator`)r=(0,t.classCheckHaveMaxCyclomaticComplexity)(e,n,!!this.isNot);else if(e.type===`FunctionLocator`)r=(0,t.functionCheckHaveMaxCyclomaticComplexity)(e,n,!!this.isNot);else throw Error(`toHaveMaxCyclomaticComplexity matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toHaveMinMaintainabilityIndex(e,n){let r;if(e.type===`FileLocator`)r=(0,t.fileCheckHaveMinMaintainabilityIndex)(e,n,!!this.isNot);else if(e.type===`FunctionLocator`)r=(0,t.functionCheckHaveMinMaintainabilityIndex)(e,n,!!this.isNot);else throw Error(`toHaveMinMaintainabilityIndex matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toHaveMaxDistanceFromMainSequence(e,n){let r;if(e.type===`SliceLocator`)r=(0,t.sliceCheckHaveMaxDistanceFromMainSequence)(e,n,!!this.isNot);else throw Error(`toHaveMaxDistanceFromMainSequence matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}},toHaveNameMatchingFileName(e){let n;if(e.type===`FunctionLocator`)n=(0,t.functionCheckHaveNameMatchingFileName)(e,!!this.isNot);else if(e.type===`ClassLocator`)n=(0,t.classCheckHaveNameMatchingFileName)(e,!!this.isNot);else throw Error(`toHaveNameMatchingFileName matcher does not support ${e.type}`);return{pass:this.isNot?!n.pass:n.pass,message:n.message}},toHaveMaxExportedFunctions(e,n){let r;if(e.type===`FileLocator`)r=(0,t.fileCheckHaveMaxExportedFunctions)(e,n,!!this.isNot);else throw Error(`toHaveMaxExportedFunctions matcher does not support ${e.type}`);return{pass:this.isNot?!r.pass:r.pass,message:r.message}}})}Object.defineProperty(e,`parseProject`,{enumerable:!0,get:function(){return t.parseProject}}),e.setupMatchers=n});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/matchers/index.ts"],"sourcesContent":["/// <reference types=\"jest\" />\nimport {\n checkDependOnExternalModule,\n checkDependOnFilesInFolder,\n checkLayeredArchitecture,\n classCheckExtendClass,\n classCheckHaveMaxCyclomaticComplexity,\n classCheckHaveModifier,\n classCheckHaveNameMatchingFileName,\n classCheckImplementInterface,\n classCheckMatchNamePattern,\n classCheckResideInFolder,\n fileCheckBeFreeOfCycles,\n fileCheckHaveMaxCyclomaticComplexity,\n fileCheckHaveMaxExportedFunctions,\n fileCheckHaveMinMaintainabilityIndex,\n fileCheckMatchNamePattern,\n functionCheckHaveExplicitReturnType,\n functionCheckHaveMaxCyclomaticComplexity,\n functionCheckHaveMinMaintainabilityIndex,\n functionCheckHaveModifier,\n functionCheckHaveNameMatchingFileName,\n functionCheckMatchNamePattern,\n type LocatorData,\n propertyCheckBeReadonly,\n type RuleResult,\n sliceCheckBeFreeOfCycles,\n sliceCheckHaveMaxDistanceFromMainSequence,\n} from '@archest/core';\nimport type { ArchestMatchers } from './models';\n\nexport * from './models';\n\n/**\n * Registers all Archest custom matchers (e.g., `toResideInFolder`, `toHaveModifier`)\n * with the global Vitest `expect` instance.\n *\n * This function must be called exactly once before any architectural tests are run.\n * The standard way to do this is to add it to a Vitest setup file.\n *\n * @example\n * ```typescript\n * // test/setup.ts\n * import { setupMatchers } from '@archest/jest';\n * setupMatchers();\n * ```\n */\nexport function setupMatchers() {\n expect.extend({\n // biome-ignore lint/suspicious/noExplicitAny: Matcher signature\n toPass(received: any) {\n let result: RuleResult;\n\n if (received?.data && received.data.type === 'LayeredArchitecture') {\n result = checkLayeredArchitecture(received.data);\n } else {\n result = received as RuleResult;\n }\n\n const { pass, message } = result;\n return {\n pass: this.isNot ? !pass : pass,\n message: pass ? () => 'Expected rule not to pass' : () => message(),\n };\n },\n\n toResideInFolder(received: LocatorData, folder: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckResideInFolder(received, folder, !!this.isNot);\n } else {\n throw new Error(\n `toResideInFolder matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveModifier(received: LocatorData, modifier: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckHaveModifier(received, modifier, !!this.isNot);\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckHaveModifier(received, modifier, !!this.isNot);\n } else {\n throw new Error(\n `toHaveModifier matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toExtendClass(received: LocatorData, className: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckExtendClass(received, className, !!this.isNot);\n } else {\n throw new Error(\n `toExtendClass matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toImplementInterface(received: LocatorData, interfaceName: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckImplementInterface(\n received,\n interfaceName,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toImplementInterface matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveExplicitReturnType(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'FunctionLocator') {\n result = functionCheckHaveExplicitReturnType(received, !!this.isNot);\n } else {\n throw new Error(\n `toHaveExplicitReturnType matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toBeReadonly(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'PropertyLocator') {\n result = propertyCheckBeReadonly(received, !!this.isNot);\n } else {\n throw new Error(\n `toBeReadonly matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toDependOnFilesInFolder(received: LocatorData, folder: string) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = checkDependOnFilesInFolder(received, folder, !!this.isNot);\n } else {\n throw new Error(\n `toDependOnFilesInFolder matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toDependOnExternalModule(\n received: LocatorData,\n moduleName: string | RegExp,\n ) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = checkDependOnExternalModule(\n received,\n moduleName,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toDependOnExternalModule matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toBeFreeOfCycles(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckBeFreeOfCycles(received, !!this.isNot);\n } else if (received.type === 'SliceLocator') {\n result = sliceCheckBeFreeOfCycles(received, !!this.isNot);\n } else {\n throw new Error(\n `toBeFreeOfCycles matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toMatchNamePattern(received: LocatorData, pattern: string | RegExp) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckMatchNamePattern(received, pattern, !!this.isNot);\n } else if (received.type === 'ClassLocator') {\n result = classCheckMatchNamePattern(received, pattern, !!this.isNot);\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckMatchNamePattern(received, pattern, !!this.isNot);\n } else {\n throw new Error(\n `toMatchNamePattern matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMaxCyclomaticComplexity(received: LocatorData, max: number) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckHaveMaxCyclomaticComplexity(\n received,\n max,\n !!this.isNot,\n );\n } else if (received.type === 'ClassLocator') {\n result = classCheckHaveMaxCyclomaticComplexity(\n received,\n max,\n !!this.isNot,\n );\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckHaveMaxCyclomaticComplexity(\n received,\n max,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toHaveMaxCyclomaticComplexity matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMinMaintainabilityIndex(received: LocatorData, min: number) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckHaveMinMaintainabilityIndex(\n received,\n min,\n !!this.isNot,\n );\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckHaveMinMaintainabilityIndex(\n received,\n min,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toHaveMinMaintainabilityIndex matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMaxDistanceFromMainSequence(received: LocatorData, max: number) {\n let result: RuleResult;\n if (received.type === 'SliceLocator') {\n result = sliceCheckHaveMaxDistanceFromMainSequence(\n received,\n max,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toHaveMaxDistanceFromMainSequence matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveNameMatchingFileName(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'FunctionLocator') {\n result = functionCheckHaveNameMatchingFileName(received, !!this.isNot);\n } else if (received.type === 'ClassLocator') {\n result = classCheckHaveNameMatchingFileName(received, !!this.isNot);\n } else {\n throw new Error(\n `toHaveNameMatchingFileName matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMaxExportedFunctions(received: LocatorData, max: number) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckHaveMaxExportedFunctions(received, max, !!this.isNot);\n } else {\n throw new Error(\n `toHaveMaxExportedFunctions matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n });\n}\n\ndeclare global {\n namespace jest {\n interface Matchers<R> extends ArchestMatchers<R> {}\n }\n}\n"],"mappings":"2UA+CA,SAAgB,GAAgB,CAC9B,OAAO,OAAO,CAEZ,OAAO,EAAe,CACpB,IAAI,EAEJ,AAGE,EAHE,GAAU,MAAQ,EAAS,KAAK,OAAS,uBAC3C,EAAA,EAAA,0BAAkC,EAAS,KAAK,CAEvC,EAGX,GAAM,CAAE,OAAM,WAAY,EAC1B,MAAO,CACL,KAAM,KAAK,MAAQ,CAAC,EAAO,EAC3B,QAAS,MAAa,gCAAoC,GAAS,CACpE,EAGH,iBAAiB,EAAuB,EAAgB,CACtD,I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ACR,8DAA8D,EAAS,OACxE,CAEH,MAAO,CACL,KAAM,KAAK,MAAQ,CAAC,EAAO,KAAO,EAAO,KACzC,QAAS,EAAO,QACjB,EAGH,2BAA2B,EAAuB,CAChD,IAAI,EACJ,GAAI,EAAS,OAAS,kBACpB,GAAA,EAAA,EAAA,uCAA+C,EAAU,CAAC,CAAC,KAAK,MAAM,SAC7D,EAAS,OAAS,eAC3B,GAAA,EAAA,EAAA,oCAA4C,EAAU,CAAC,CAAC,KAAK,MAAM,MAEnE,MAAU,MACR,uDAAuD,EAAS,OACjE,CAEH,MAAO,CACL,KAAM,KAAK,MAAQ,CAAC,EAAO,KAAO,EAAO,KACzC,QAAS,EAAO,QACjB,EAGH,2BAA2B,EAAuB,EAAa,CAC7D,IAAI,EACJ,GAAI,EAAS,OAAS,cACpB,GAAA,EAAA,EAAA,mCAA2C,EAAU,EAAK,CAAC,CAAC,KAAK,MAAM,MAEvE,MAAU,MACR,uDAAuD,EAAS,OACjE,CAEH,MAAO,CACL,KAAM,KAAK,MAAQ,CAAC,EAAO,KAAO,EAAO,KACzC,QAAS,EAAO,QACjB,EAEJ,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,162 @@
1
+ import { checkDependOnExternalModule as e, checkDependOnFilesInFolder as t, checkLayeredArchitecture as n, classCheckExtendClass as r, classCheckHaveMaxCyclomaticComplexity as i, classCheckHaveModifier as a, classCheckHaveNameMatchingFileName as o, classCheckImplementInterface as s, classCheckMatchNamePattern as c, classCheckResideInFolder as l, fileCheckBeFreeOfCycles as u, fileCheckHaveMaxCyclomaticComplexity as d, fileCheckHaveMaxExportedFunctions as f, fileCheckHaveMinMaintainabilityIndex as p, fileCheckMatchNamePattern as m, functionCheckHaveExplicitReturnType as h, functionCheckHaveMaxCyclomaticComplexity as g, functionCheckHaveMinMaintainabilityIndex as _, functionCheckHaveModifier as v, functionCheckHaveNameMatchingFileName as y, functionCheckMatchNamePattern as b, parseProject as x, propertyCheckBeReadonly as S, sliceCheckBeFreeOfCycles as C, sliceCheckHaveMaxDistanceFromMainSequence as w } from "@archest/core";
2
+ //#region src/matchers/index.ts
3
+ function T() {
4
+ expect.extend({
5
+ toPass(e) {
6
+ let t;
7
+ t = e?.data && e.data.type === "LayeredArchitecture" ? n(e.data) : e;
8
+ let { pass: r, message: i } = t;
9
+ return {
10
+ pass: this.isNot ? !r : r,
11
+ message: r ? () => "Expected rule not to pass" : () => i()
12
+ };
13
+ },
14
+ toResideInFolder(e, t) {
15
+ let n;
16
+ if (e.type === "ClassLocator") n = l(e, t, !!this.isNot);
17
+ else throw Error(`toResideInFolder matcher does not support ${e.type}`);
18
+ return {
19
+ pass: this.isNot ? !n.pass : n.pass,
20
+ message: n.message
21
+ };
22
+ },
23
+ toHaveModifier(e, t) {
24
+ let n;
25
+ if (e.type === "ClassLocator") n = a(e, t, !!this.isNot);
26
+ else if (e.type === "FunctionLocator") n = v(e, t, !!this.isNot);
27
+ else throw Error(`toHaveModifier matcher does not support ${e.type}`);
28
+ return {
29
+ pass: this.isNot ? !n.pass : n.pass,
30
+ message: n.message
31
+ };
32
+ },
33
+ toExtendClass(e, t) {
34
+ let n;
35
+ if (e.type === "ClassLocator") n = r(e, t, !!this.isNot);
36
+ else throw Error(`toExtendClass matcher does not support ${e.type}`);
37
+ return {
38
+ pass: this.isNot ? !n.pass : n.pass,
39
+ message: n.message
40
+ };
41
+ },
42
+ toImplementInterface(e, t) {
43
+ let n;
44
+ if (e.type === "ClassLocator") n = s(e, t, !!this.isNot);
45
+ else throw Error(`toImplementInterface matcher does not support ${e.type}`);
46
+ return {
47
+ pass: this.isNot ? !n.pass : n.pass,
48
+ message: n.message
49
+ };
50
+ },
51
+ toHaveExplicitReturnType(e) {
52
+ let t;
53
+ if (e.type === "FunctionLocator") t = h(e, !!this.isNot);
54
+ else throw Error(`toHaveExplicitReturnType matcher does not support ${e.type}`);
55
+ return {
56
+ pass: this.isNot ? !t.pass : t.pass,
57
+ message: t.message
58
+ };
59
+ },
60
+ toBeReadonly(e) {
61
+ let t;
62
+ if (e.type === "PropertyLocator") t = S(e, !!this.isNot);
63
+ else throw Error(`toBeReadonly matcher does not support ${e.type}`);
64
+ return {
65
+ pass: this.isNot ? !t.pass : t.pass,
66
+ message: t.message
67
+ };
68
+ },
69
+ toDependOnFilesInFolder(e, n) {
70
+ let r;
71
+ if (e.type === "FileLocator") r = t(e, n, !!this.isNot);
72
+ else throw Error(`toDependOnFilesInFolder matcher does not support ${e.type}`);
73
+ return {
74
+ pass: this.isNot ? !r.pass : r.pass,
75
+ message: r.message
76
+ };
77
+ },
78
+ toDependOnExternalModule(t, n) {
79
+ let r;
80
+ if (t.type === "FileLocator") r = e(t, n, !!this.isNot);
81
+ else throw Error(`toDependOnExternalModule matcher does not support ${t.type}`);
82
+ return {
83
+ pass: this.isNot ? !r.pass : r.pass,
84
+ message: r.message
85
+ };
86
+ },
87
+ toBeFreeOfCycles(e) {
88
+ let t;
89
+ if (e.type === "FileLocator") t = u(e, !!this.isNot);
90
+ else if (e.type === "SliceLocator") t = C(e, !!this.isNot);
91
+ else throw Error(`toBeFreeOfCycles matcher does not support ${e.type}`);
92
+ return {
93
+ pass: this.isNot ? !t.pass : t.pass,
94
+ message: t.message
95
+ };
96
+ },
97
+ toMatchNamePattern(e, t) {
98
+ let n;
99
+ if (e.type === "FileLocator") n = m(e, t, !!this.isNot);
100
+ else if (e.type === "ClassLocator") n = c(e, t, !!this.isNot);
101
+ else if (e.type === "FunctionLocator") n = b(e, t, !!this.isNot);
102
+ else throw Error(`toMatchNamePattern matcher does not support ${e.type}`);
103
+ return {
104
+ pass: this.isNot ? !n.pass : n.pass,
105
+ message: n.message
106
+ };
107
+ },
108
+ toHaveMaxCyclomaticComplexity(e, t) {
109
+ let n;
110
+ if (e.type === "FileLocator") n = d(e, t, !!this.isNot);
111
+ else if (e.type === "ClassLocator") n = i(e, t, !!this.isNot);
112
+ else if (e.type === "FunctionLocator") n = g(e, t, !!this.isNot);
113
+ else throw Error(`toHaveMaxCyclomaticComplexity matcher does not support ${e.type}`);
114
+ return {
115
+ pass: this.isNot ? !n.pass : n.pass,
116
+ message: n.message
117
+ };
118
+ },
119
+ toHaveMinMaintainabilityIndex(e, t) {
120
+ let n;
121
+ if (e.type === "FileLocator") n = p(e, t, !!this.isNot);
122
+ else if (e.type === "FunctionLocator") n = _(e, t, !!this.isNot);
123
+ else throw Error(`toHaveMinMaintainabilityIndex matcher does not support ${e.type}`);
124
+ return {
125
+ pass: this.isNot ? !n.pass : n.pass,
126
+ message: n.message
127
+ };
128
+ },
129
+ toHaveMaxDistanceFromMainSequence(e, t) {
130
+ let n;
131
+ if (e.type === "SliceLocator") n = w(e, t, !!this.isNot);
132
+ else throw Error(`toHaveMaxDistanceFromMainSequence matcher does not support ${e.type}`);
133
+ return {
134
+ pass: this.isNot ? !n.pass : n.pass,
135
+ message: n.message
136
+ };
137
+ },
138
+ toHaveNameMatchingFileName(e) {
139
+ let t;
140
+ if (e.type === "FunctionLocator") t = y(e, !!this.isNot);
141
+ else if (e.type === "ClassLocator") t = o(e, !!this.isNot);
142
+ else throw Error(`toHaveNameMatchingFileName matcher does not support ${e.type}`);
143
+ return {
144
+ pass: this.isNot ? !t.pass : t.pass,
145
+ message: t.message
146
+ };
147
+ },
148
+ toHaveMaxExportedFunctions(e, t) {
149
+ let n;
150
+ if (e.type === "FileLocator") n = f(e, t, !!this.isNot);
151
+ else throw Error(`toHaveMaxExportedFunctions matcher does not support ${e.type}`);
152
+ return {
153
+ pass: this.isNot ? !n.pass : n.pass,
154
+ message: n.message
155
+ };
156
+ }
157
+ });
158
+ }
159
+ //#endregion
160
+ export { x as parseProject, T as setupMatchers };
161
+
162
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/matchers/index.ts"],"sourcesContent":["/// <reference types=\"jest\" />\nimport {\n checkDependOnExternalModule,\n checkDependOnFilesInFolder,\n checkLayeredArchitecture,\n classCheckExtendClass,\n classCheckHaveMaxCyclomaticComplexity,\n classCheckHaveModifier,\n classCheckHaveNameMatchingFileName,\n classCheckImplementInterface,\n classCheckMatchNamePattern,\n classCheckResideInFolder,\n fileCheckBeFreeOfCycles,\n fileCheckHaveMaxCyclomaticComplexity,\n fileCheckHaveMaxExportedFunctions,\n fileCheckHaveMinMaintainabilityIndex,\n fileCheckMatchNamePattern,\n functionCheckHaveExplicitReturnType,\n functionCheckHaveMaxCyclomaticComplexity,\n functionCheckHaveMinMaintainabilityIndex,\n functionCheckHaveModifier,\n functionCheckHaveNameMatchingFileName,\n functionCheckMatchNamePattern,\n type LocatorData,\n propertyCheckBeReadonly,\n type RuleResult,\n sliceCheckBeFreeOfCycles,\n sliceCheckHaveMaxDistanceFromMainSequence,\n} from '@archest/core';\nimport type { ArchestMatchers } from './models';\n\nexport * from './models';\n\n/**\n * Registers all Archest custom matchers (e.g., `toResideInFolder`, `toHaveModifier`)\n * with the global Vitest `expect` instance.\n *\n * This function must be called exactly once before any architectural tests are run.\n * The standard way to do this is to add it to a Vitest setup file.\n *\n * @example\n * ```typescript\n * // test/setup.ts\n * import { setupMatchers } from '@archest/jest';\n * setupMatchers();\n * ```\n */\nexport function setupMatchers() {\n expect.extend({\n // biome-ignore lint/suspicious/noExplicitAny: Matcher signature\n toPass(received: any) {\n let result: RuleResult;\n\n if (received?.data && received.data.type === 'LayeredArchitecture') {\n result = checkLayeredArchitecture(received.data);\n } else {\n result = received as RuleResult;\n }\n\n const { pass, message } = result;\n return {\n pass: this.isNot ? !pass : pass,\n message: pass ? () => 'Expected rule not to pass' : () => message(),\n };\n },\n\n toResideInFolder(received: LocatorData, folder: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckResideInFolder(received, folder, !!this.isNot);\n } else {\n throw new Error(\n `toResideInFolder matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveModifier(received: LocatorData, modifier: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckHaveModifier(received, modifier, !!this.isNot);\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckHaveModifier(received, modifier, !!this.isNot);\n } else {\n throw new Error(\n `toHaveModifier matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toExtendClass(received: LocatorData, className: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckExtendClass(received, className, !!this.isNot);\n } else {\n throw new Error(\n `toExtendClass matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toImplementInterface(received: LocatorData, interfaceName: string) {\n let result: RuleResult;\n if (received.type === 'ClassLocator') {\n result = classCheckImplementInterface(\n received,\n interfaceName,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toImplementInterface matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveExplicitReturnType(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'FunctionLocator') {\n result = functionCheckHaveExplicitReturnType(received, !!this.isNot);\n } else {\n throw new Error(\n `toHaveExplicitReturnType matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toBeReadonly(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'PropertyLocator') {\n result = propertyCheckBeReadonly(received, !!this.isNot);\n } else {\n throw new Error(\n `toBeReadonly matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toDependOnFilesInFolder(received: LocatorData, folder: string) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = checkDependOnFilesInFolder(received, folder, !!this.isNot);\n } else {\n throw new Error(\n `toDependOnFilesInFolder matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toDependOnExternalModule(\n received: LocatorData,\n moduleName: string | RegExp,\n ) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = checkDependOnExternalModule(\n received,\n moduleName,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toDependOnExternalModule matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toBeFreeOfCycles(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckBeFreeOfCycles(received, !!this.isNot);\n } else if (received.type === 'SliceLocator') {\n result = sliceCheckBeFreeOfCycles(received, !!this.isNot);\n } else {\n throw new Error(\n `toBeFreeOfCycles matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toMatchNamePattern(received: LocatorData, pattern: string | RegExp) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckMatchNamePattern(received, pattern, !!this.isNot);\n } else if (received.type === 'ClassLocator') {\n result = classCheckMatchNamePattern(received, pattern, !!this.isNot);\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckMatchNamePattern(received, pattern, !!this.isNot);\n } else {\n throw new Error(\n `toMatchNamePattern matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMaxCyclomaticComplexity(received: LocatorData, max: number) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckHaveMaxCyclomaticComplexity(\n received,\n max,\n !!this.isNot,\n );\n } else if (received.type === 'ClassLocator') {\n result = classCheckHaveMaxCyclomaticComplexity(\n received,\n max,\n !!this.isNot,\n );\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckHaveMaxCyclomaticComplexity(\n received,\n max,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toHaveMaxCyclomaticComplexity matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMinMaintainabilityIndex(received: LocatorData, min: number) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckHaveMinMaintainabilityIndex(\n received,\n min,\n !!this.isNot,\n );\n } else if (received.type === 'FunctionLocator') {\n result = functionCheckHaveMinMaintainabilityIndex(\n received,\n min,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toHaveMinMaintainabilityIndex matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMaxDistanceFromMainSequence(received: LocatorData, max: number) {\n let result: RuleResult;\n if (received.type === 'SliceLocator') {\n result = sliceCheckHaveMaxDistanceFromMainSequence(\n received,\n max,\n !!this.isNot,\n );\n } else {\n throw new Error(\n `toHaveMaxDistanceFromMainSequence matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveNameMatchingFileName(received: LocatorData) {\n let result: RuleResult;\n if (received.type === 'FunctionLocator') {\n result = functionCheckHaveNameMatchingFileName(received, !!this.isNot);\n } else if (received.type === 'ClassLocator') {\n result = classCheckHaveNameMatchingFileName(received, !!this.isNot);\n } else {\n throw new Error(\n `toHaveNameMatchingFileName matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n\n toHaveMaxExportedFunctions(received: LocatorData, max: number) {\n let result: RuleResult;\n if (received.type === 'FileLocator') {\n result = fileCheckHaveMaxExportedFunctions(received, max, !!this.isNot);\n } else {\n throw new Error(\n `toHaveMaxExportedFunctions matcher does not support ${received.type}`,\n );\n }\n return {\n pass: this.isNot ? !result.pass : result.pass,\n message: result.message,\n };\n },\n });\n}\n\ndeclare global {\n namespace jest {\n interface Matchers<R> extends ArchestMatchers<R> {}\n }\n}\n"],"mappings":";;AA+CA,SAAgB,IAAgB;AAC9B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CAAC,CAAC,KAAK,MACR;OAED,OAAU,MACR,8DAA8D,EAAS,OACxE;AAEH,UAAO;IACL,MAAM,KAAK,QAAQ,CAAC,EAAO,OAAO,EAAO;IACzC,SAAS,EAAO;IACjB;;EAGH,2BAA2B,GAAuB;GAChD,IAAI;AACJ,OAAI,EAAS,SAAS,kBACpB,KAAS,EAAsC,GAAU,CAAC,CAAC,KAAK,MAAM;YAC7D,EAAS,SAAS,eAC3B,KAAS,EAAmC,GAAU,CAAC,CAAC,KAAK,MAAM;OAEnE,OAAU,MACR,uDAAuD,EAAS,OACjE;AAEH,UAAO;IACL,MAAM,KAAK,QAAQ,CAAC,EAAO,OAAO,EAAO;IACzC,SAAS,EAAO;IACjB;;EAGH,2BAA2B,GAAuB,GAAa;GAC7D,IAAI;AACJ,OAAI,EAAS,SAAS,cACpB,KAAS,EAAkC,GAAU,GAAK,CAAC,CAAC,KAAK,MAAM;OAEvE,OAAU,MACR,uDAAuD,EAAS,OACjE;AAEH,UAAO;IACL,MAAM,KAAK,QAAQ,CAAC,EAAO,OAAO,EAAO;IACzC,SAAS,EAAO;IACjB;;EAEJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { ArchestMatchers } from './models';
2
+ export * from './models';
3
+ /**
4
+ * Registers all Archest custom matchers (e.g., `toResideInFolder`, `toHaveModifier`)
5
+ * with the global Vitest `expect` instance.
6
+ *
7
+ * This function must be called exactly once before any architectural tests are run.
8
+ * The standard way to do this is to add it to a Vitest setup file.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // test/setup.ts
13
+ * import { setupMatchers } from '@archest/jest';
14
+ * setupMatchers();
15
+ * ```
16
+ */
17
+ export declare function setupMatchers(): void;
18
+ declare global {
19
+ namespace jest {
20
+ interface Matchers<R> extends ArchestMatchers<R> {
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Native Vitest Matchers provided by Archest for architectural testing.
3
+ *
4
+ * This interface extends Vitest's `Assertion` interface to provide fluent assertions
5
+ * on your codebase's architectural structure.
6
+ */
7
+ export interface ArchestMatchers<R = unknown> {
8
+ /**
9
+ * Asserts that the evaluated architectural rule passes.
10
+ * Primarily used for complex rules like LayeredArchitecture.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const architecture = project.layeredArchitecture()
15
+ * .layer('Domain', 'domain')
16
+ * .layer('Infrastructure', 'infrastructure');
17
+ *
18
+ * expect(architecture.whereLayer('Domain').shouldNotAccessAnyLayer().check()).toPass();
19
+ * ```
20
+ */
21
+ toPass(): void;
22
+ /**
23
+ * Asserts that the located elements physically reside within the specified folder.
24
+ * Supports ClassLocators.
25
+ *
26
+ * @param folder - The folder name or path pattern the elements must reside in.
27
+ * @example
28
+ * ```typescript
29
+ * const controllers = project.getClasses({ matchNamePattern: /Controller$/ });
30
+ * expect(controllers).toResideInFolder('controllers');
31
+ * ```
32
+ */
33
+ toResideInFolder(folder: string): void;
34
+ /**
35
+ * Asserts that the located elements have the specified TypeScript modifier.
36
+ * Supports ClassLocators and FunctionLocators.
37
+ *
38
+ * @param modifier - The AST modifier to enforce (e.g., 'export', 'abstract', 'async').
39
+ * @example
40
+ * ```typescript
41
+ * const helpers = project.getFunctions({ inFolder: 'utils' });
42
+ * expect(helpers).toHaveModifier('export');
43
+ * ```
44
+ */
45
+ toHaveModifier(modifier: 'export' | 'default' | 'abstract' | 'async' | 'private' | 'public'): void;
46
+ /**
47
+ * Asserts that the located classes extend the specified base class.
48
+ * Supports ClassLocators.
49
+ *
50
+ * @param className - The name of the class that must be extended.
51
+ * @example
52
+ * ```typescript
53
+ * const repositories = project.getClasses({ matchNamePattern: /Repository$/ });
54
+ * expect(repositories).toExtendClass('BaseRepository');
55
+ * ```
56
+ */
57
+ toExtendClass(className: string): void;
58
+ /**
59
+ * Asserts that the located classes implement the specified interface.
60
+ * Supports ClassLocators.
61
+ *
62
+ * @param interfaceName - The name of the interface that must be implemented.
63
+ * @example
64
+ * ```typescript
65
+ * const useCases = project.getClasses({ inFolder: 'use-cases' });
66
+ * expect(useCases).toImplementInterface('IUseCase');
67
+ * ```
68
+ */
69
+ toImplementInterface(interfaceName: string): void;
70
+ /**
71
+ * Asserts that the located functions have an explicit TypeScript return type.
72
+ * Supports FunctionLocators.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const domainFunctions = project.getFunctions({ inFolder: 'domain' });
77
+ * expect(domainFunctions).toHaveExplicitReturnType();
78
+ * ```
79
+ */
80
+ toHaveExplicitReturnType(): void;
81
+ /**
82
+ * Asserts that the located properties are marked as readonly.
83
+ * Supports PropertyLocators.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const dtoProps = project.getProperties({ classPattern: /Dto$/ });
88
+ * expect(dtoProps).toBeReadonly();
89
+ * ```
90
+ */
91
+ toBeReadonly(): void;
92
+ /**
93
+ * Asserts that the located files import dependencies from the specified folder.
94
+ * Supports FileLocators.
95
+ *
96
+ * @param folder - The target folder that must be imported.
97
+ * @example
98
+ * ```typescript
99
+ * const uiFiles = project.getFiles({ inFolder: 'ui' });
100
+ * expect(uiFiles).not.toDependOnFilesInFolder('database');
101
+ * ```
102
+ */
103
+ toDependOnFilesInFolder(folder: string): void;
104
+ /**
105
+ * Asserts that a file locator depends on a specific external module (e.g. from node_modules).
106
+ * Supports FileLocators.
107
+ *
108
+ * @param moduleName - The exact string name or RegExp of the external package (e.g. 'vue', 'lodash').
109
+ * @example
110
+ * ```typescript
111
+ * it('should only use gql-tada inside the graphql module', () => {
112
+ * expect(
113
+ * project.files().not.matching(/src\/graphql\//)
114
+ * ).not.toDependOnExternalModule('gql-tada');
115
+ * });
116
+ * ```
117
+ */
118
+ toDependOnExternalModule(moduleName: string | RegExp): void;
119
+ /**
120
+ * Analyzes the AST dependency graph and asserts that the queried elements are entirely free of circular dependencies.
121
+ * Supports FileLocators and SliceLocators.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const domainFiles = project.getFiles({ inFolder: 'domain' });
126
+ * expect(domainFiles).toBeFreeOfCycles();
127
+ * ```
128
+ */
129
+ toBeFreeOfCycles(): void;
130
+ /**
131
+ * Asserts that the name of the located element matches the provided string or RegExp pattern.
132
+ * Supports FileLocators, ClassLocators, and FunctionLocators.
133
+ *
134
+ * @param pattern - The string or RegExp pattern that must match the name.
135
+ * @example
136
+ * ```typescript
137
+ * const controllers = project.getClasses({ withDecorator: 'Controller' });
138
+ * expect(controllers).toMatchNamePattern(/Controller$/);
139
+ * ```
140
+ */
141
+ toMatchNamePattern(pattern: string | RegExp): void;
142
+ /**
143
+ * Computes the cyclomatic complexity of the AST and asserts it is less than or equal to the maximum.
144
+ * Supports FileLocators, ClassLocators, and FunctionLocators.
145
+ *
146
+ * @param max - The maximum allowed cyclomatic complexity.
147
+ * @example
148
+ * ```typescript
149
+ * const coreFunctions = project.getFunctions({ inFolder: 'core' });
150
+ * expect(coreFunctions).toHaveMaxCyclomaticComplexity(10);
151
+ * ```
152
+ */
153
+ toHaveMaxCyclomaticComplexity(max: number): void;
154
+ /**
155
+ * Computes the maintainability index based on Halstead metrics and asserts it is greater than or equal to the minimum.
156
+ * Supports FileLocators and FunctionLocators.
157
+ *
158
+ * @param min - The minimum acceptable maintainability index (0-100).
159
+ * @example
160
+ * ```typescript
161
+ * const coreFiles = project.getFiles({ inFolder: 'core' });
162
+ * expect(coreFiles).toHaveMinMaintainabilityIndex(65);
163
+ * ```
164
+ */
165
+ toHaveMinMaintainabilityIndex(min: number): void;
166
+ /**
167
+ * Computes the Robert C. Martin Distance from the Main Sequence for the slice and asserts it is less than or equal to the maximum.
168
+ * Supports SliceLocators.
169
+ *
170
+ * @param max - The maximum allowed distance from the main sequence (0 to 1).
171
+ * @example
172
+ * ```typescript
173
+ * const slices = project.getSlices('modules/(*)/');
174
+ * expect(slices).toHaveMaxDistanceFromMainSequence(0.3);
175
+ * ```
176
+ */
177
+ toHaveMaxDistanceFromMainSequence(max: number): void;
178
+ /**
179
+ * Asserts that the exported class or function name exactly matches the name of its parent file.
180
+ * Supports ClassLocators and FunctionLocators.
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const allFunctions = project.getFunctions();
185
+ * expect(allFunctions).toHaveNameMatchingFileName();
186
+ * ```
187
+ */
188
+ toHaveNameMatchingFileName(): void;
189
+ /**
190
+ * Asserts that the located file does not export more than the specified maximum number of functions.
191
+ * Supports FileLocators.
192
+ *
193
+ * @param max - The maximum number of allowed exported functions per file.
194
+ * @example
195
+ * ```typescript
196
+ * const utils = project.getFiles({ inFolder: 'utils' });
197
+ * expect(utils).toHaveMaxExportedFunctions(5);
198
+ * ```
199
+ */
200
+ toHaveMaxExportedFunctions(max: number): void;
201
+ }
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { ClassLocatorData } from './types';
3
+ export declare function classCheckExtendClass(locator: ClassLocatorData, className: string, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { ClassLocatorData } from './types';
3
+ export declare function classCheckHaveMaxCyclomaticComplexity(locator: ClassLocatorData, max: number, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { ClassLocatorData } from './types';
3
+ export declare function classCheckHaveModifier(locator: ClassLocatorData, modifierStr: string, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { ClassLocatorData } from './types';
3
+ export declare function classCheckHaveNameMatchingFileName(locator: ClassLocatorData, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { ClassLocatorData } from './types';
3
+ export declare function classCheckImplementInterface(locator: ClassLocatorData, interfaceName: string, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { ClassLocatorData } from './types';
3
+ export declare function classCheckMatchNamePattern(locator: ClassLocatorData, pattern: string | RegExp, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { ClassLocatorData } from './types';
3
+ export declare function classCheckResideInFolder(locator: ClassLocatorData, targetFolder: string, isNot: boolean): RuleResult;
@@ -0,0 +1,5 @@
1
+ import { ClassData, ProjectData } from '../dto';
2
+ import { ClassLocatorData, ClassQueryOptions } from './types';
3
+ export declare function locateClasses(classes: (ClassData & {
4
+ _filePath: string;
5
+ })[], projectData: ProjectData, options?: ClassQueryOptions): ClassLocatorData;
@@ -0,0 +1,25 @@
1
+ import { ClassData, ProjectData } from '../dto';
2
+ export interface ClassLocatorData {
3
+ type: 'ClassLocator';
4
+ classes: (ClassData & {
5
+ _filePath: string;
6
+ })[];
7
+ projectData: ProjectData;
8
+ }
9
+ /**
10
+ * Options to filter classes when querying the AST via `getClasses()`.
11
+ */
12
+ export interface ClassQueryOptions {
13
+ /** Filters classes to only include those residing in a specific folder path. */
14
+ inFolder?: string;
15
+ /** Filters classes by a string or RegExp matching their name. */
16
+ matchNamePattern?: string | RegExp;
17
+ /** Filters classes to only include those that have the specified decorator applied. */
18
+ withDecorator?: string;
19
+ /** Filters classes to only include those extending the specified base class. */
20
+ extending?: string;
21
+ /** Filters classes to only include those implementing the specified interface. */
22
+ implementing?: string;
23
+ /** Filters classes to only include those with the specified AST modifier (e.g., 'export', 'abstract'). */
24
+ havingModifier?: string;
25
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Represents the entire parsed project structure containing all analyzed files.
3
+ * This is the root node returned by the native Rust parser.
4
+ */
5
+ export interface ProjectData {
6
+ /** A list of all files that were successfully parsed in the project workspace. */
7
+ files: FileData[];
8
+ }
9
+ /**
10
+ * Represents a single source file in the project.
11
+ * Contains information about its path, dependencies, and all nested code blocks.
12
+ */
13
+ export interface FileData {
14
+ /** The absolute path to the file. */
15
+ path: string;
16
+ /** An array of all classes defined within this file. */
17
+ classes: ClassData[];
18
+ /** An array of all top-level or exported functions defined within this file. */
19
+ functions: FunctionData[];
20
+ /** An array of properties extracted from classes or objects in the file. */
21
+ properties: PropertyData[];
22
+ /** An array of raw module paths this file imports (e.g., './utils', 'react'). */
23
+ dependencies?: string[];
24
+ /** An array of external module imports (e.g., 'react', 'lodash'). */
25
+ external_dependencies?: string[];
26
+ }
27
+ /**
28
+ * Represents a class declaration extracted from a TypeScript or JavaScript file.
29
+ * Includes architectural metadata such as its hierarchy and complexity.
30
+ */
31
+ export interface ClassData {
32
+ /** The name of the class, or null if it is an anonymous class. */
33
+ name: string | null;
34
+ /** True if the class has an 'export' modifier. */
35
+ is_exported: boolean;
36
+ /** True if the class has an 'export default' modifier. */
37
+ is_default: boolean;
38
+ /** True if the class is marked as abstract. */
39
+ is_abstract: boolean;
40
+ /** The name of the parent class it extends, if any. */
41
+ extends: string | null;
42
+ /** An array of interface names this class implements. */
43
+ implements: string[];
44
+ /** An array of decorator names applied to the class. */
45
+ decorators: string[];
46
+ /** The computed McCabe cyclomatic complexity of the class methods. */
47
+ cyclomatic_complexity?: number;
48
+ /** The computed Halstead maintainability index (0-100). */
49
+ maintainability_index?: number;
50
+ }
51
+ /**
52
+ * Represents a function declaration or arrow function extracted from a file.
53
+ */
54
+ export interface FunctionData {
55
+ /** The name of the function, or null if anonymous. */
56
+ name: string | null;
57
+ /** True if the function is exported from the file. */
58
+ is_exported: boolean;
59
+ /** True if the function is marked as async. */
60
+ is_async: boolean;
61
+ /** True if the function is defined at the root level of the file context. */
62
+ is_top_level: boolean;
63
+ /** True if the function explicitly declares a return type. */
64
+ has_explicit_return_type: boolean;
65
+ /** The computed McCabe cyclomatic complexity of the function body. */
66
+ cyclomatic_complexity?: number;
67
+ /** The computed Halstead maintainability index (0-100). */
68
+ maintainability_index?: number;
69
+ }
70
+ /**
71
+ * Represents a class property or interface member extracted from the AST.
72
+ */
73
+ export interface PropertyData {
74
+ /** The name of the property. */
75
+ name: string;
76
+ /** True if the property is marked with the 'readonly' modifier. */
77
+ is_readonly: boolean;
78
+ }
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { FileLocatorData } from './types';
3
+ export declare function checkDependOnExternalModule(locator: FileLocatorData, moduleName: string | RegExp, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { FileLocatorData } from './types';
3
+ export declare function checkDependOnFilesInFolder(locator: FileLocatorData, targetFolder: string, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { FileLocatorData } from './types';
3
+ export declare function fileCheckBeFreeOfCycles(locator: FileLocatorData, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { FileLocatorData } from './types';
3
+ export declare function fileCheckHaveMaxCyclomaticComplexity(locator: FileLocatorData, max: number, isNot: boolean): RuleResult;
@@ -0,0 +1,3 @@
1
+ import { RuleResult } from '../types';
2
+ import { FileLocatorData } from './types';
3
+ export declare function fileCheckHaveMaxExportedFunctions(locator: FileLocatorData, max: number, isNot: boolean): RuleResult;