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

Commit a9543c0

Browse files
authored
switch to using package:dart_flutter_team_lints (#247)
* switch to using package:dart_flutter_team_lints * address example lints * require dart 2.19 * update action config
1 parent 36407ea commit a9543c0

File tree

7 files changed

+14
-22
lines changed

7 files changed

+14
-22
lines changed

.github/workflows/test-package.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
# Add macos-latest and/or windows-latest if relevant for this package
4848
os: [ubuntu-latest]
4949
# Add stable if the package should also be tested on stable
50-
sdk: [2.18.0, dev]
50+
sdk: [2.19.0, dev]
5151
steps:
5252
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
5353
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Change the validation of `mandatory` options; they now perform validation when
44
the value is retrieved (from the `ArgResults` object), instead of when the
55
args are parsed.
6+
* Require Dart 2.19.
67

78
## 2.4.1
89

analysis_options.yaml

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
# https://dart.dev/guides/language/analysis-options
2-
include: package:lints/recommended.yaml
2+
3+
include: package:dart_flutter_team_lints/analysis_options.yaml
34

45
linter:
56
rules:
6-
- always_declare_return_types
7-
- avoid_dynamic_calls
87
- avoid_unused_constructor_parameters
98
- cancel_subscriptions
109
- comment_references
11-
- directives_ordering
12-
- lines_longer_than_80_chars
1310
- literal_only_boolean_expressions
1411
- missing_whitespace_between_adjacent_strings
1512
- no_adjacent_strings_in_list
1613
- no_runtimeType_toString
17-
- omit_local_variable_types
1814
- package_api_docs
1915
- prefer_relative_imports
20-
- prefer_single_quotes
2116
- test_types_in_equals
22-
- throw_in_finally
23-
- type_annotate_public_apis
24-
- unawaited_futures
2517
- unnecessary_await_in_return
26-
- unnecessary_lambdas
2718
- use_super_parameters

example/command_runner/draw.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SquareCommand extends Command<String> {
3333

3434
@override
3535
FutureOr<String>? run() {
36-
final size = int.parse(argResults?['size'] ?? '20');
36+
final size = int.parse(argResults?['size'] as String? ?? '20');
3737
final char = (globalResults?['char'] as String?)?[0] ?? '#';
3838
return draw(size, size, char, (x, y) => true);
3939
}
@@ -55,7 +55,7 @@ class CircleCommand extends Command<String> {
5555

5656
@override
5757
FutureOr<String>? run() {
58-
final size = 2 * int.parse(argResults?['radius'] ?? '10');
58+
final size = 2 * int.parse(argResults?['radius'] as String? ?? '10');
5959
final char = (globalResults?['char'] as String?)?[0] ?? '#';
6060
return draw(size, size, char, (x, y) => x * x + y * y < 1);
6161
}
@@ -93,7 +93,7 @@ class EquilateralTriangleCommand extends Command<String> {
9393

9494
@override
9595
FutureOr<String>? run() {
96-
final size = int.parse(argResults?['size'] ?? '20');
96+
final size = int.parse(argResults?['size'] as String? ?? '20');
9797
final char = (globalResults?['char'] as String?)?[0] ?? '#';
9898
return drawTriangle(size, size * sqrt(3) ~/ 2, char);
9999
}
@@ -116,8 +116,8 @@ class IsoscelesTriangleCommand extends Command<String> {
116116

117117
@override
118118
FutureOr<String>? run() {
119-
final width = int.parse(argResults?['width'] ?? '50');
120-
final height = int.parse(argResults?['height'] ?? '10');
119+
final width = int.parse(argResults?['width'] as String? ?? '50');
120+
final height = int.parse(argResults?['height'] as String? ?? '10');
121121
final char = (globalResults?['char'] as String?)?[0] ?? '#';
122122
return drawTriangle(width, height, char);
123123
}

lib/command_runner.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ class CommandRunner<T> {
192192
commands = command._subcommands as Map<String, Command<T>>;
193193
commandString += ' ${argResults.name}';
194194

195-
if (argResults.options.contains('help') && argResults['help']) {
195+
if (argResults.options.contains('help') && (argResults['help'] as bool)) {
196196
command.printUsage();
197197
return null;
198198
}
199199
}
200200

201-
if (topLevelResults['help']) {
201+
if (topLevelResults['help'] as bool) {
202202
command!.printUsage();
203203
return null;
204204
}

pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ topics:
99
- cli
1010

1111
environment:
12-
sdk: '>=2.18.0 <3.0.0'
12+
sdk: '>=2.19.0 <4.0.0'
1313

1414
dev_dependencies:
15-
lints: ^2.0.0
15+
dart_flutter_team_lints: ^1.0.0
1616
test: ^1.16.0

test/command_runner_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -755,5 +755,5 @@ class _MandatoryOptionCommand extends Command {
755755
String get name => 'mandatory-option-command';
756756

757757
@override
758-
String run() => argResults!['mandatory-option'];
758+
String run() => argResults!['mandatory-option'] as String;
759759
}

0 commit comments

Comments
 (0)