Rules / Correctness / unused-files

unused-files

cross-file/correctness/unused-files
recommendedcross-file
Same as check-unused-files · Dart Code Metrics
Cross-file rule. This rule 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, and expect it to do more work on large projects than a single-file rule.

Report lib/ files that nothing in the project references.

Flags a file under lib/ that no other file imports, exports, or includes as a part, and that is not itself an entrypoint. Such a file is typically dead code left behind after its callers were removed — it bloats the package and misleads readers into thinking it is live. Files that declare a top-level main, and part of files (which belong to their owning library), are never reported. This is a cross-file rule: it runs in the cross-file pass over the whole analyzed file set and is configured under the top-level cross-file section rather than linter.

Invalid

feature.dartdart
// Referenced by main.dart, and owns a part file — both stay unflagged.
part 'feature_part.dart';

void runFeature() {
  featurePartHelper();
}

No diagnostics in this file.

How to configure

Set the severity of unused-files in your falcon.json under the cross-file section:

falcon.jsonjson
{
  "cross-file": {
    "rules": {
      "correctness": {
        "unused-files": "error"
      }
    }
  }
}