Skip to content

Latest commit

 

History

History
66 lines (50 loc) · 1.79 KB

File metadata and controls

66 lines (50 loc) · 1.79 KB

Circular Dependencies Linter

⚠️ This Angular Builder is not recommended for enterprise usage.
Despite the fact that it works as intended, codebase is not covered with tests. Moreover Builder API may change. Use it on your own risks.

This Angular Builder finds all circular dependencies in your project and prints easy-to-read message about found issues:

> ng run my-very-best-angular-project:lint-circular-deps

Found circular dependencies: 2

● 1:
⭡⮧ app/component-module-service/invalid.component.ts
⭡⭣ app/component-module-service/invalid.module.ts
⮤⭣ app/component-module-service/invalid.service.ts

● 2:
⭡⮧ app/interface-type/invalid.interface.ts
⮤⭣ app/interface-type/invalid.type.ts

You may use this Builder in your CI pipeline: it returns non-zero exit code if there are some circular dependencies.

Installation & Usage

To use this builder, ng-builders package should be already installed. If not, follow steps, described here.

Now, update your angular.json with the following:

// angular.json
{
  ...
  "projects": {
    "my-very-best-angular-project": { // 👈 your project name
      "architect": {
        "lint-circular-deps": { // 👈 CLI command name
          "builder": "ng-builders:circular-dependencies-linter", // 👈 required builder
          "options": {
            "tsConfig": "./tsconfig.app.json"
          }
        }
      }
    }
  },
  ...
}

Then, check that everything works as needed:

ng run my-very-best-angular-project:lint-circular-deps

If there are no circular dependencies, you'll get something like this:

> ng run with-circular-dependencies:lint-circular-deps

No circular dependencies found.