Skip to content

Validation ​

Project graph ​

Before validating a project, Morando builds its dependency graph. Traversal starts from the project's entry point, usually the file configured as your application bundler's entry point (src/index.ts or src/index.tsx), and continues until all project files have been analyzed.

Each traversed file is analyzed to determine whether it violates any validation rules. The main factors are:

  • file name
  • file location in the project
  • dependencies (imports)

During this process, the file is also classified into a layer. Traversal then continues to each dependency unless it is excluded, as discussed in the next section.

Morando does not analyze your code

By design, Morando does not analyze your code's semantics. It only extracts dependencies from imports. File locations and dependencies are all the architecture linter needs to build and validate a project's graph.

Gradual migration ​

Morando's key design principle is to allow existing codebases to migrate to the new architecture gradually, at a pace that works best for each team. For that reason, files need to be removable from architecture validation, either temporarily or permanently. Morando distinguishes between:

  • excluded - files that Morando does not include in the project graph. They cannot cause validation errors. If your project imports such a file, Morando treats that import as if it did not exist.

  • legacy - files that participate in building the project graph but do not produce validation errors.

If your project starts with any legacy files, the goal is to slowly reduce the list until it's empty and the migration is done.

Validation rules ​

As discussed in the preceding section, only files that are neither excluded nor legacy can produce validation errors. Excluded files are not part of the project graph, while legacy files participate in the graph without producing errors.

The rules below define what Morando enforces. The concepts behind them are discussed in the previous chapters.

RequiredForbidden
File
  • Belongs to a module.
  • Is classified into a layer.
  • Depends on a file in a higher layer.
  • Has a circular dependency with another file.
Module
  • Belongs to a domain.
  • Contains folders other than layer folders.
  • Has a circular dependency with another module.
Domain
  • Is located in the project's source root.
  • Contains only modules.
--
Layer
  • Is assigned to a stack.
--
Layer folder
  • Belongs to a module.
  • Has a name that matches one of the project's layers.
  • Contains folders.

Read the table as a checklist.

Each row describes one of Morando's concepts. A dash (--) in the Forbidden column means no additional forbidden conditions are defined for that concept.