directives-ordering
Same as directives_ordering in Dart lints
- Group
- Style
- Path
lint/style/directives-ordering- Default
- Off, opt in
- Origin
- Dart lints
- Rule
- 219 of 512
Flags import and export directives that break the Effective Dart ordering.
Directives are grouped into sections — dart: first, then package:, then
relative URIs — with exports in their own section after every import, and each
section sorted alphabetically. Every directive is reported at most once, with
the first broken convention in this order:
import 'package:a/a.dart';
import 'dart:async'; // flagged: 'dart:' imports go first
import 'package:c/c.dart';
import 'package:b/b.dart'; // flagged: sort sections alphabetically
import 'x.dart';
export 'y.dart'; // flagged: exports go after all imports
import 'package:d/d.dart'; // flagged: 'package:' before relative
All package: directives form one section; the analyzer does not separate
the current package from third-party packages. @docImports of the library
documentation comment form their own sections, checked like imports.
Invalid
// 'dart:' imports must come first.
import 'package:collection/collection.dart';
import 'dart:async';
import 'dart:math';
void main() {}import 'package:collection/collection.dart';import 'dart:async';import 'dart:async';import 'dart:math';Valid
// The Effective Dart order: dart, package, relative; exports last.
library;
import 'dart:async';
import 'dart:math';
import 'package:collection/collection.dart';
import 'package:http/http.dart';
import 'package:http_parser/http_parser.dart';
import 'package:path/path.dart';
import 'a.dart';
import 'b.dart';
import 'src/c.dart';
export 'dart:io';
export 'package:collection/collection.dart';
export 'a.dart';
part 'part.dart';
void main() {}Configure directives-ordering
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"directives-ordering": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/directives-ordering: <reason>More style rules
- do-not-use-environment
do_not_use_environmentDisallow reading compilation environment declarations, including type aliases.
- double-literal-format
double-literal-formatFlags double literals written with redundant or missing digits.
- empty-constructor-bodies
empty_constructor_bodiesrecommendedFlags constructors with an empty block body
{}. - enum-constants-ordering
Flags enum constants whose declared names violate the configured order.
- eol-at-end-of-file
eol_at_end_of_filerecommendedFlags a non-empty file that does not end with exactly one line break.
- extend-equatableequatable
Require Equatable semantics for configured class/file name patterns.
- file-names
file_namesrecommendedEnforces
lowercase_with_underscoresfor source file names. - flutter-style-todos
flutter_style_todosFlags
TODOcomments that do not follow the Flutter style// TODO(username): message, https://URL-to-issue.