Rules / Style / library-prefixes

library-prefixes

lint/style/library-prefixes
recommended
Same as library_prefixes · Dart lints

Flags import prefixes that are not lower_case_with_underscores.

An import prefix (import '...' as foo;) is a library-style name and should use lower_case_with_underscores to match Dart's package and library naming, keeping qualified references uniform. Lowercase letters, digits, underscores, and $ are all permitted; the presence of any uppercase letter is what makes a prefix invalid.

Invalid

example.dartdart
// Import prefixes must be lower_case_with_underscores.

import 'dart:math' as Math;
import 'dart:async' as MyAsync;
import 'dart:convert' as JSON;
import 'dart:io' as IO;
import 'dart:collection' as CollectionLib;
import 'dart:typed_data' as TypedData;
Use `lowercase_with_underscores` for a library prefix.
2
3import 'dart:math' as Math;
Use `lowercase_with_underscores` for a library prefix.
3import 'dart:math' as Math;
4import 'dart:async' as MyAsync;
Use `lowercase_with_underscores` for a library prefix.
4import 'dart:async' as MyAsync;
5import 'dart:convert' as JSON;
Use `lowercase_with_underscores` for a library prefix.
5import 'dart:convert' as JSON;
6import 'dart:io' as IO;
Use `lowercase_with_underscores` for a library prefix.
6import 'dart:io' as IO;
7import 'dart:collection' as CollectionLib;
Use `lowercase_with_underscores` for a library prefix.
7import 'dart:collection' as CollectionLib;
8import 'dart:typed_data' as TypedData;

Valid

example.dartdart
// lower_case_with_underscores import prefixes.

import 'dart:math' as math;
import 'dart:async' as async_lib;
import 'dart:convert' as convert;
import 'dart:io' as io;
import 'dart:collection' as collection;
import 'dart:typed_data' as typed_data;

How to configure

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

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