sort-pub-dependencies

Same as sort_pub_dependencies in Dart lints

Path
cross-file/correctness/sort-pub-dependencies
Default
Off, opt in
Origin
Dart lints
Rule
438 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.

Require pubspec.yaml dependency sections to be sorted alphabetically.

The dependencies, dev_dependencies, and dependency_overrides mappings of every package pubspec.yaml enclosing an analyzed file are walked in source order, and the first package name that sorts before its predecessor is reported; like the official rule, each section reports at most one name (the first break in the order) so that fixing it and re-running converges. Names compare by UTF-16 code units, exactly as Dart's String.compareTo, so Zebra sorts before apple. Malformed YAML (including duplicate keys) and non-mapping sections are skipped. This is a cross-file rule because it reads the package manifest rather than Dart source.

Invalid

bad-case/lib/main.dartdart
void main() {}

No diagnostics in this file.

Configure sort-pub-dependencies

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

falcon.jsonjson
{
  "cross-file": {
    "rules": {
      "correctness": {
        "sort-pub-dependencies": "error"
      }
    }
  }
}

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

example.dartdart
// falcon-ignore cross-file/correctness/sort-pub-dependencies: <reason>