ArchUnitTS - v2.2.0
    Preparing search index...

    Class CustomFileCheckableCondition

    Custom condition for checking files using user-defined logic. This class allows for highly flexible architectural rules that can't be expressed through the standard API methods. Users can define custom functions that receive file information and return boolean results.

    The custom condition function receives a FileInfo object containing details about each file including path, content, exports, imports, etc.

    // Custom rule: files should have specific exports
    projectFiles()
    .inFolder('services')
    .should()
    .adhereTo(
    (fileInfo) => fileInfo.exports.includes('default'),
    'Service files must have default export'
    )
    .check();

    // Custom rule: files should not exceed certain complexity
    projectFiles()
    .matching(/.*\.ts$/)
    .should()
    .adhereTo(
    (fileInfo) => fileInfo.content.split('\n').length < 100,
    'Files should not exceed 100 lines'
    )
    .check();

    Implements

    Index

    Constructors

    Properties

    tsConfigFilePath?: string
    message?: string
    filters?: Filter[]
    isNegated?: boolean

    Methods

    • Executes the custom file condition check.

      For each file matching the preconditions, the custom condition function is called with a FileInfo object. If the function returns false for any file, a violation is generated with the specified message.

      Parameters

      • Optionaloptions: CheckOptions

        Optional check options including allowEmptyTests and logging

      Returns Promise<Violation[]>

      Promise<Violation[]> Array of violations where custom condition failed