Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 59118ce

Browse files
authored
Fix directives_ordering for non-pub packages. (#2596)
1 parent 03fa407 commit 59118ce

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.3.1
2+
3+
- `directives_ordering` now checks ordering of `package:` imports in code
4+
outside pub packages
5+
16
# 1.3.0
27

38
- `non_constant_identifier_names` updated to check local variables, for-loop
@@ -22,7 +27,7 @@
2227

2328
- fixed `prefer_mixin` to properly make exceptions for `dart.collection` legacy
2429
mixins
25-
- improved formatting of source examples in docs
30+
- improved formatting of source examples in docs
2631
- new lint: `use_build_context_synchronously` (experimental)
2732
- new lint: `avoid_multiple_declarations_per_line`
2833

lib/src/rules/directives_ordering.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,14 @@ class _Visitor extends SimpleAstVisitor<void> {
271271
_checkSectionInOrder(lintedNodes, relativeExports);
272272

273273
var projectName = project?.name;
274-
if (projectName != null) {
274+
if (projectName == null) {
275+
// Not a pub package. Package directives should be sorted in one block.
276+
var packageImports = importDirectives.where(_isPackageDirective);
277+
var packageExports = exportDirectives.where(_isPackageDirective);
278+
279+
_checkSectionInOrder(lintedNodes, packageImports);
280+
_checkSectionInOrder(lintedNodes, packageExports);
281+
} else {
275282
var packageBox = _PackageBox(projectName);
276283

277284
var thirdPartyPackageImports =

0 commit comments

Comments
 (0)