avoid-duplicate-named-imports

Path
lint/correctness/avoid-duplicate-named-imports
Default
Off, opt in
Origin
Falcon
Rule
53 of 512

Flags imports of the same library that differ only in their name prefix. Conditional URIs, deferred loading, combinators, and metadata must match. Consolidate uses under one import before removing the other directive.

Invalid

example.dartdart
import 'a.dart' as first;
import 'a.dart' as second;
import 'b.dart';
import 'b.dart' as b;
import 'c.dart' as c;
import 'c.dart';
import 'd.dart' as d show D;
import 'd.dart' as other show D;
import 'e.dart' deferred as e;
import 'e.dart' deferred as otherE;
import 'f.dart' if (dart.library.io) 'io.dart' as f;
import 'f.dart' if (dart.library.io) 'io.dart' as otherF;
This library is already imported with the same visibility — consolidate uses under one import and remove the duplicate.
1import 'a.dart' as first;
2import 'a.dart' as second;
This library is already imported with the same visibility — consolidate uses under one import and remove the duplicate.
3import 'b.dart';
4import 'b.dart' as b;
This library is already imported with the same visibility — consolidate uses under one import and remove the duplicate.
5import 'c.dart' as c;
6import 'c.dart';
This library is already imported with the same visibility — consolidate uses under one import and remove the duplicate.
7import 'd.dart' as d show D;
8import 'd.dart' as other show D;
This library is already imported with the same visibility — consolidate uses under one import and remove the duplicate.
9import 'e.dart' deferred as e;
10import 'e.dart' deferred as otherE;
This library is already imported with the same visibility — consolidate uses under one import and remove the duplicate.
11import 'f.dart' if (dart.library.io) 'io.dart' as f;
12import 'f.dart' if (dart.library.io) 'io.dart' as otherF;

Valid

example.dartdart
import 'a.dart' as same;
import 'b.dart' as same;
import 'c.dart' as c show A;
import 'c.dart' as otherC show B;
import 'd.dart' as d hide A;
import 'd.dart' as otherD hide B;
import 'e.dart' as e;
import 'e.dart' deferred as otherE;
import 'f.dart' if (dart.library.io) 'io.dart' as f;
import 'f.dart' if (dart.library.html) 'html.dart' as otherF;
import 'g.dart' if (dart.library.io) 'one.dart' as g;
import 'g.dart' if (dart.library.io) 'two.dart' as otherG;
import 'plain.dart';
import 'plain.dart';

Configure avoid-duplicate-named-imports

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "correctness": {
        "avoid-duplicate-named-imports": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/correctness/avoid-duplicate-named-imports: <reason>