always-use-package-imports

Same as always_use_package_imports in Dart lints

Path
lint/correctness/always-use-package-imports
Default
Off, opt in
Origin
Dart lints
Rule
9 of 512

Disallow relative imports in libraries under a package's lib/ directory.

The rule runs only for files inside the enclosing package's lib/ directory (the nearest pubspec.yaml decides the package; files outside any package are skipped, like the analyzer's isInLibDir). Every import whose URI parses with an empty scheme is reported, so import 'src/a.dart'; must be spelled import 'package:<name>/src/a.dart';. package: and dart: imports, exports, and conditional alternatives are not checked; relative imports that reach into lib/ from outside it belong to avoid_relative_lib_imports. Incompatible with prefer-relative-imports.

Invalid

bin/tool.dartdart
import '../lib/b.dart';

void main() {}

No diagnostics in this file.

Valid

example.dartdart
import 'dart:async';
import 'package:app/src/a.dart';
import 'package:other/other.dart' as other;
import 'package:app/b.dart' show B;
import 'package:app/c.dart' deferred as c;

export 'src/exported.dart';

void main() {}

Configure always-use-package-imports

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "correctness": {
        "always-use-package-imports": "error"
      }
    }
  }
}

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

example.dartdart
// falcon-ignore lint/correctness/always-use-package-imports: <reason>