Merge branch 'main' into move-do-not-use
diff --git a/test/rules/all.dart b/test/rules/all.dart
index 28de7cb..f0584a2 100644
--- a/test/rules/all.dart
+++ b/test/rules/all.dart
@@ -49,6 +49,7 @@
as deprecated_member_use_from_same_package;
import 'directives_ordering_test.dart' as directives_ordering;
import 'discarded_futures_test.dart' as discarded_futures;
+import 'do_not_use_environment_test.dart' as do_not_use_environment;
import 'empty_catches_test.dart' as empty_catches;
import 'empty_statements_test.dart' as empty_statements;
import 'eol_at_end_of_file_test.dart' as eol_at_end_of_file;
@@ -188,6 +189,7 @@
deprecated_member_use_from_same_package.main();
directives_ordering.main();
discarded_futures.main();
+ do_not_use_environment.main();
empty_catches.main();
empty_statements.main();
eol_at_end_of_file.main();
diff --git a/test/rules/do_not_use_environment_test.dart b/test/rules/do_not_use_environment_test.dart
new file mode 100644
index 0000000..8457acb
--- /dev/null
+++ b/test/rules/do_not_use_environment_test.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
+// 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:test_reflective_loader/test_reflective_loader.dart';
+
+import '../rule_test_support.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(DoNotUseEnvironmentTest);
+ });
+}
+
+@reflectiveTest
+class DoNotUseEnvironmentTest extends LintRuleTest {
+ @override
+ String get lintRule => 'do_not_use_environment';
+ test_bool() async {
+ await assertDiagnostics(r'''
+void f() {
+ bool.fromEnvironment('key');
+}
+''', [
+ lint(13, 20),
+ ]);
+ }
+
+ test_hasEnvironment() async {
+ await assertDiagnostics(r'''
+void f() {
+ bool.hasEnvironment('key');
+}
+''', [
+ lint(13, 19),
+ ]);
+ }
+
+ test_int() async {
+ await assertDiagnostics(r'''
+void f() {
+ int.fromEnvironment('key');
+}
+''', [
+ lint(13, 19),
+ ]);
+ }
+
+ test_string() async {
+ await assertDiagnostics(r'''
+void f() {
+ String.fromEnvironment('key');
+}
+''', [
+ lint(13, 22),
+ ]);
+ }
+}
diff --git a/test_data/rules/do_not_use_environment.dart b/test_data/rules/do_not_use_environment.dart
deleted file mode 100644
index 80d4f83..0000000
--- a/test_data/rules/do_not_use_environment.dart
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// 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.
-
-// test w/ `dart test -N do_not_use_environment`
-
-void f() {
- int.fromEnvironment('key'); // LINT
- bool.fromEnvironment('key'); // LINT
- String.fromEnvironment('key'); //LINT
- bool.hasEnvironment('key'); //LINT
-}