no-leading-underscores-for-library-prefixes
Same as no_leading_underscores_for_library_prefixes in Dart lints
- Group
- Style
- Path
lint/style/no-leading-underscores-for-library-prefixes- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 288 of 512
Flags import prefixes that begin with an underscore.
In Dart a leading underscore signals library privacy, but an import prefix
is only a local alias — it is never exported and cannot be made private, so
the underscore is meaningless noise that only muddies the privacy
convention. Rename the prefix without the leading underscore. A wildcard
prefix composed solely of underscores (e.g. _) is exempt, since it is an
intentional throwaway name rather than a misapplied privacy marker.
Invalid
// Import prefixes must not start with an underscore.
import 'dart:math' as _math;
import 'dart:async' as _async;
import 'dart:convert' as _convert;
import 'dart:io' as _io;
import 'dart:collection' as _collection;
import 'dart:typed_data' as _typed_data; import 'dart:math' as _math;import 'dart:math' as _math;import 'dart:async' as _async;import 'dart:async' as _async;import 'dart:convert' as _convert;import 'dart:convert' as _convert;import 'dart:io' as _io;import 'dart:io' as _io;import 'dart:collection' as _collection;import 'dart:collection' as _collection;import 'dart:typed_data' as _typed_data;Valid
// Import prefixes without leading underscores (all-underscore wildcard is fine).
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 _;Configure no-leading-underscores-for-library-prefixes
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"no-leading-underscores-for-library-prefixes": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/no-leading-underscores-for-library-prefixes: <reason>More style rules
- no-leading-underscores-for-local-identifiers
no_leading_underscores_for_local_identifiersrecommendedFlags local variables and parameters whose names begin with an underscore.
- no-literal-bool-comparisons
no_literal_bool_comparisonsFlags boolean literals compared or combined with a non-nullable
bool. - no-magic-number
no-magic-numberFlags unnamed numeric literals (magic numbers) used inline in expressions.
- no-object-declaration
no-object-declarationFlags class members declared with the type
Object(orObject?). - no-runtime-type-to-string
no_runtimeType_toStringAvoid calling
toString()onruntimeType. - non-constant-identifier-names
non_constant_identifier_namesrecommendedFlags non-constant identifiers that are not written in lowerCamelCase.
- omit-local-variable-types
omit_local_variable_typesFlags local variable type annotations that repeat the initializer's type.
- only-throw-errors
only_throw_errorsrecommendedOnly throw instances of classes that extend
ExceptionorError.