mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
don't lint unnecessary lib names pre unnamedLibraries
Related to: https://github.com/dart-lang/lints/issues/181 Change-Id: I4a247fa93c6659d5082d2cb6047aedc6a13a4209 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359321 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
parent
19decc4270
commit
6a9c709afd
|
@ -2,6 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
|
||||
|
@ -65,6 +66,11 @@ class UnnecessaryLibraryName extends LintRule {
|
|||
@override
|
||||
void registerNodeProcessors(
|
||||
NodeLintRegistry registry, LinterContext context) {
|
||||
if (!context.currentUnit.unit.featureSet
|
||||
.isEnabled(Feature.unnamedLibraries)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var visitor = _Visitor(this);
|
||||
registry.addLibraryDirective(this, visitor);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,13 @@ library name;
|
|||
]);
|
||||
}
|
||||
|
||||
test_namedLibrary_preUnnamedLibraries() async {
|
||||
await assertNoDiagnostics(r'''
|
||||
// @dart = 2.14
|
||||
library name;
|
||||
''');
|
||||
}
|
||||
|
||||
test_unnamedLibrary() async {
|
||||
await assertNoDiagnostics(r'''
|
||||
library;
|
||||
|
|
Loading…
Reference in a new issue