depend-on-referenced-packages

Same as depend_on_referenced_packages in Dart lints

Path
cross-file/correctness/depend-on-referenced-packages
Default
On (recommended)
Origin
Dart lints
Rule
215 of 512
recommendedcross-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.

Require imported packages to be declared in pubspec.yaml.

Imports from lib/ and bin/ must name a regular dependency. Imports from development-only locations such as test/ and tool/ may also name a dev-dependency. SDK imports and imports of the package itself are ignored. Like the analyzer, only the primary URI is checked, not conditional alternatives. When undeclared-dependencies is enabled for a file, that rule owns missing declarations and dev-dependencies imported from lib/; this rule only adds its stricter executable/build-hook dependency check, avoiding duplicate reports.

Invalid

bad-hook/hook/build.dartdart
import 'package:http/http.dart';

void main() {}
bad-hook/hook/build.dartThe imported package `http` isn't a dependency of the importing package.
1import 'package:http/http.dart';

Configure depend-on-referenced-packages

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

falcon.jsonjson
{
  "cross-file": {
    "rules": {
      "correctness": {
        "depend-on-referenced-packages": "error"
      }
    }
  }
}

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

example.dartdart
// falcon-ignore cross-file/correctness/depend-on-referenced-packages: <reason>
  • deprecated-member-use-from-same-packagedeprecated_member_use_from_same_package

    Reports uses of deprecated declarations from their own package.

  • diagnostic-describe-all-propertiesdiagnostic_describe_all_propertiesflutter

    Requires every public property of a Diagnosticable class to be referenced in its debug methods.

  • discarded-futuresdiscarded_futures

    Don't discard Futures returned by calls in synchronous functions.

  • dispose-fieldsrecommendedflutter

    Requires other owned disposable State fields to be released in dispose().

  • dispose-focus-node-and-timerrecommendedflutter

    Requires owned FocusNode and Timer fields to be released in State.dispose().

  • dispose-provided-instancesrecommendedriverpod

    Flags provider-created instances with a dispose method that lack ref.onDispose cleanup.

  • dispose-provider-resourcesrecommendedriverpod

    Flags provider-created resources without autoDispose or ref.onDispose cleanup.

  • dispose-providersrecommendedprovider

    Requires cleanup callbacks for disposable values created by package:provider's Provider.