◆ arch_guard

IDE warnings

Shows arch_guard rules as warnings on the offending import line, in VS Code, Android Studio / IntelliJ and dart analyze / flutter analyze, with quick fixes.

Warning When Quick fixes
layer_violation An import crosses a layer boundary that allowed_imports does not allow. Remove the import · Allow the import in the config
forbidden_package An import uses a package or core library listed under forbidden_packages. Remove the import
circular_dependency This import closes a cycle among files in lib/. It is the one import whose removal breaks the cycle, or shrinks it the most. Remove the import

Install

Requires Dart 3.10 / Flutter 3.38 or later.

# analysis_options.yaml
plugins:
  arch_guard_lint: ^0.2.0

Restart the Dart analysis server afterwards (in VS Code: Dart: Restart Analysis Server).

Quick fixes

Open the quick-fix menu on a warning (VS Code: Ctrl+. / Cmd+.).

The fixes run one at a time, never in bulk or through dart fix. Removing an import or loosening a rule should be your call. There is no “allow” fix for forbidden_packages: weakening a “never import this” rule should be a deliberate edit.

Circular dependencies

circular_dependency uses the same cycle-breaking hint as the CLI. Each cycle gets one warning, on the import to remove:

warning - lib/domain/user.dart:1:8 - This import closes a circular dependency of 2 files: lib/domain/user_service.dart -> lib/domain/user.dart -> lib/domain/user_service.dart. Removing it breaks the cycle. Move the code both files need into a third file, or invert the dependency. - circular_dependency

To turn it off:

# analysis_options.yaml
plugins:
  arch_guard_lint:
    version: ^0.2.0
    diagnostics:
      circular_dependency: false

How it works

Suppress a single warning:

// ignore: arch_guard_lint/layer_violation
import '../data/repo.dart';