prefer_library_prefixes

SeverityQuick FixOptions
Info

Details

DO use library prefixes for configured libraries to avoid name conflicts and increase code readability.

Bad
import 'dart:developer';
import 'dart:math';

print(log(e));
log('message');
Good
import 'dart:developer' as developer;
import 'dart:math' as math;

print(math.log(math.e));
developer.log('message');

Usage

To enable the prefer_library_prefixes rule, add prefer_library_prefixes under plugins > pyramid_lint > diagnostics in your analysis_options.yaml file:

plugins:
  pyramid_lint: <version>
    diagnostics:
      prefer_library_prefixes: true

Options

OptionTypeDescriptionDefault Value
librariesList<String>Libraries that must be imported with a prefix.[]

To configure which libraries require a prefix, add the libraries under plugins > pyramid_lint > options:

plugins:
  pyramid_lint: <version>
    diagnostics:
      prefer_library_prefixes: true
    options:
      prefer_library_prefixes:
        libraries:
          - dart:developer
          - dart:math
          - package:http/http.dart