Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to using package:dart_flutter_team_lints #247

Merged
merged 4 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
# Add macos-latest and/or windows-latest if relevant for this package
os: [ubuntu-latest]
# Add stable if the package should also be tested on stable
sdk: [2.18.0, dev]
sdk: [2.19.0, dev]
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Change the validation of `mandatory` options; they now perform validation when
the value is retrieved (from the `ArgResults` object), instead of when the
args are parsed.
* Require Dart 2.19.

## 2.4.1

Expand Down
13 changes: 2 additions & 11 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
# https://dart.dev/guides/language/analysis-options
include: package:lints/recommended.yaml

include: package:dart_flutter_team_lints/analysis_options.yaml

linter:
rules:
- always_declare_return_types
- avoid_dynamic_calls
- avoid_unused_constructor_parameters
- cancel_subscriptions
- comment_references
- directives_ordering
- lines_longer_than_80_chars
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- omit_local_variable_types
- package_api_docs
- prefer_relative_imports
- prefer_single_quotes
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_lambdas
- use_super_parameters
10 changes: 5 additions & 5 deletions example/command_runner/draw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SquareCommand extends Command<String> {

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

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

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

@override
FutureOr<String>? run() {
final width = int.parse(argResults?['width'] ?? '50');
final height = int.parse(argResults?['height'] ?? '10');
final width = int.parse(argResults?['width'] as String? ?? '50');
final height = int.parse(argResults?['height'] as String? ?? '10');
final char = (globalResults?['char'] as String?)?[0] ?? '#';
return drawTriangle(width, height, char);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ class CommandRunner<T> {
commands = command._subcommands as Map<String, Command<T>>;
commandString += ' ${argResults.name}';

if (argResults.options.contains('help') && argResults['help']) {
if (argResults.options.contains('help') && (argResults['help'] as bool)) {
command.printUsage();
return null;
}
}

if (topLevelResults['help']) {
if (topLevelResults['help'] as bool) {
command!.printUsage();
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ topics:
- cli

environment:
sdk: '>=2.18.0 <3.0.0'
sdk: '>=2.19.0 <4.0.0'

dev_dependencies:
lints: ^2.0.0
dart_flutter_team_lints: ^1.0.0
test: ^1.16.0
2 changes: 1 addition & 1 deletion test/command_runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -755,5 +755,5 @@ class _MandatoryOptionCommand extends Command {
String get name => 'mandatory-option-command';

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