no-import-cycles

Path
cross-file/correctness/no-import-cycles
Default
Off, opt in
Origin
Falcon
Rule
287 of 512
cross-file

Cross-file rule. It runs in falcon's whole-project pass, analyzing relationships across every file rather than one file at a time. Configure it under the top-level cross-file key.

Report mutually dependent components of imported or exported library files.

Cycles couple libraries and make dependency boundaries harder to maintain. Each diagnostic includes the complete chain, ending back at its first file. Import and export targets include every conditional alternative; part and part of directives are not dependency edges. Only analyzed, resolved files participate; package URIs without a known package identity are skipped. Canonical path aliases and repeated directives share one edge. Each mutually dependent component is reported once, including self-imports. The chain is a shortest cycle through its lexicographically first canonical file, not an enumeration of all cycles within that component. Configure this project-wide rule under the cross-file section.

Invalid

bad_conditional_export/lib/a.dartdart
export 'stub.dart'
    if (dart.library.html) 'b.dart';
bad_conditional_export/lib/a.dartRemove a dependency to break this import/export cycle: `lib/a.dart` -> `lib/b.dart` -> `lib/a.dart`.
1export 'stub.dart'
2 if (dart.library.html) 'b.dart';

Configure no-import-cycles

Set its severity in falcon.json under the cross-file section. See the configuration guide.

falcon.jsonjson
{
  "cross-file": {
    "rules": {
      "correctness": {
        "no-import-cycles": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore cross-file/correctness/no-import-cycles: <reason>
  • no-logic-in-create-stateno_logic_in_create_staterecommendedflutter

    Require StatefulWidget.createState to return only a fresh zero-argument Flutter State construction.

  • no-self-assignmentsno_self_assignmentsrecommended

    Flags assignments of a variable to itself, such as x = x;.

  • null-check-on-nullable-type-parameternull_check_on_nullable_type_parameterrecommended

    Flags a null assertion x! on a nullable type parameter T? whose expected type is T or T? for a potentially nullable T, and null-assert patterns whose matched value is a nullable type parameter.

  • null-closuresnull_closuresrecommended

    Reject literal null in the closure slots of curated SDK APIs.

  • prefer-correct-json-casts

    Decode JSON containers using their actual runtime generic types.

  • prefer-define-hero-tagflutter

    Require an explicit heroTag on Flutter FloatingActionButton constructors.

  • prefer-expect-latertest

    Requires expectLater when a canonical expect call receives an unawaited Future.

  • prefer-immutable-bloc-eventsrecommendedbloc

    Flags Bloc event classes without an explicit @immutable annotation.