Rules / Style / unnecessary-library-name

unnecessary-library-name

lint/style/unnecessary-library-name
recommended
Same as unnecessary_library_name · Dart lints

Flags a library directive that carries an explicit name.

Since Dart 2.19 the library directive no longer needs a name: part of directives can reference their parent by URI, and library-level doc comments and annotations attach to a bare library;. A named library is legacy syntax that only adds a global identifier which can collide across packages. Remove the name, keeping the library; directive itself if it anchors documentation or annotations.

Invalid

example.dartdart
library foo;
Library names are not necessary.
1library foo;

Valid

example.dartdart
class Model {}

How to configure

Set the severity of unnecessary-library-name in your falcon.json:

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "unnecessary-library-name": "error"
      }
    }
  }
}