unnecessary-library-directive

Same as unnecessary_library_directive in Dart lints

Group
Style
Path
lint/style/unnecessary-library-directive
Default
On (recommended)
Origin
Dart lints
Rule
459 of 512
recommended

Flags a library directive that has neither a doc comment nor annotations.

A library directive is only needed to anchor library-level documentation or annotations (and, historically, a name). Without either it is noise:

library;                 // flagged

/// Utilities for parsing.
library;                 // fine: documented

@TestOn('browser')
library;                 // fine: annotated

Libraries that declare part files are skipped, since parts may still refer to the library by name.

Invalid

example.dartdart
// A bare library directive with no doc comment or annotation.
library;

void main() {}
Library directives without comments or annotations should be avoided.
1// A bare library directive with no doc comment or annotation.
2library;

Valid

example.dartdart
/// Utilities for parsing.
library;

void main() {}

Configure unnecessary-library-directive

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

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

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

example.dartdart
// falcon-ignore lint/style/unnecessary-library-directive: <reason>