-
Notifications
You must be signed in to change notification settings - Fork 169
add lint use_string_in_part_of_directives #3567
Conversation
@@ -0,0 +1,68 @@ | |||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you consider migrating this test to the reflective_test_loader
style? These run faster and are easier to debug.
FWIW ConditionalUriDoesNotExistTest
and PreferConstConstructorsTest
are examples of tests that uses this style for tests that require multiple files.
(Aside: we should really write up some docs for this... 😬 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this rule I need several files. I don't find example dealing with multiple files. Do you have an example of such case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
In this case newFile2
creates a.dart
which is imported by the test file in assertNoDiagnostics
.
test_deferred_arg() async {
newFile2('$testPackageLibPath/a.dart', '''
class A {
const A();
}
const aa = A();
''');
await assertNoDiagnostics(r'''
import 'a.dart' deferred as a;
class B {
const B(Object a);
}
main() {
var b = B(a.aa);
print(b);
}
''');
}
You can call newFile2
multiple times with different library names ($testPackageLibPath/b.dart
etc.) to get more libraries to import into your test file if needed.
I need to run out for a but but if you get stuck, feel free to share how far you get and I'm happy to take a look.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help. Tests are now migrated. PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super. Thanks!
* add lint use_string_in_part_of_directives * migrate test to reflective_test_loader style
Description
From effective dart:
DO use strings in
part of
directives.BAD:
part of my_library;
GOOD:
Fixes dart-lang/sdk#58777