Closed spydon closed 10 months ago
I added a few more uncontroversial rules that was previously not used in Canonical repos - https://github.com/canonical/ubuntu-flutter-plugins/pull/336/commits/e8f53f2411975ad6eec0427f9f940ec831462017. You can read about each of them here:
https://dart.dev/tools/linter-rules/always_put_required_named_parameters_first https://dart.dev/tools/linter-rules/avoid_multiple_declarations_per_line https://dart.dev/tools/linter-rules/avoid_returning_this https://dart.dev/tools/linter-rules/avoid_type_to_string https://dart.dev/tools/linter-rules/avoid_void_async https://dart.dev/tools/linter-rules/close_sinks https://dart.dev/tools/linter-rules/comment_references https://dart.dev/tools/linter-rules/deprecated_consistency https://dart.dev/tools/linter-rules/literal_only_boolean_expressions https://dart.dev/tools/linter-rules/no_adjacent_strings_in_list https://dart.dev/tools/linter-rules/no_runtimeType_toString https://dart.dev/tools/linter-rules/noop_primitive_operations https://dart.dev/tools/linter-rules/parameter_assignments https://dart.dev/tools/linter-rules/prefer_constructors_over_static_methods https://dart.dev/tools/linter-rules/prefer_void_to_null https://dart.dev/tools/linter-rules/test_types_in_equals https://dart.dev/tools/linter-rules/throw_in_finally https://dart.dev/tools/linter-rules/unnecessary_await_in_return https://dart.dev/tools/linter-rules/unnecessary_null_checks https://dart.dev/tools/linter-rules/unnecessary_raw_strings https://dart.dev/tools/linter-rules/unnecessary_statements https://dart.dev/tools/linter-rules/use_enums https://dart.dev/tools/linter-rules/use_if_null_to_convert_nulls_to_bools https://dart.dev/tools/linter-rules/use_is_even_rather_than_modulo https://dart.dev/tools/linter-rules/use_late_for_private_fields_and_variables https://dart.dev/tools/linter-rules/void_checks
There is also a more "controversial" rule, require_trailing_commas
, that I think we should add. But we can discuss that one later and possibly do it in a follow-up.
I also saw that lines_longer_than_80_chars
had been explicitly deactivated before, but the rule seems to be follow almost everywhere, maybe we could check if we would want to add that again too?
Didn't yet have the time to look at all those rules, but I'm wondering how we should go about enforcing them in the existing projects. Agree on a set of rules here, publish the package, dart/flutter fix ..
all the things in a single, large PR for each project? Or would it be better to break it down into smaller steps and enforce one rule after the other until we converge?
Didn't yet have the time to look at all those rules, but I'm wondering how we should go about enforcing them in the existing projects. Agree on a set of rules here, publish the package,
dart/flutter fix ..
all the things in a single, large PR for each project? Or would it be better to break it down into smaller steps and enforce one rule after the other until we converge?
I think it depends on how many fixes that the project needs, I think most projects in this repository won't need much changing at all, but some other projects probably need a bit more changes. I can explore it a bit once it is merged.
Didn't yet have the time to look at all those rules, but I'm wondering how we should go about enforcing them in the existing projects. Agree on a set of rules here, publish the package,
dart/flutter fix ..
all the things in a single, large PR for each project? Or would it be better to break it down into smaller steps and enforce one rule after the other until we converge?I think it depends on how many fixes that the project needs, I think most projects in this repository won't need much changing at all, but some other projects probably need a bit more changes. I can explore it a bit once it is merged.
Just had a closer look and tried applying those rules in ubuntu-desktop-provision and app-center - there'd be only a few trivial changes in the app-center :)
So should we merge this as-is and publish it, then think about adding require_trailing_commas
and lines_longer_than_80_chars
later?
Just had a closer look and tried applying those rules in ubuntu-desktop-provision and app-center - there'd be only a few trivial changes in the app-center :)
So should we merge this as-is and publish it, then think about adding
require_trailing_commas
andlines_longer_than_80_chars
later?
Sounds like a good plan!
Since there are multiple different sets of linting rules across the different repositories I thought it would be a good idea to come up with a a rule-set that can be consistently used across all repositories containing Dart or Flutter code.
I have taken all the rules that have been previously applied across the repositories in
ubuntu-flutter-plugins
,ubuntu-desktop-provision
andubuntu-desktop-installer
.It also includes a script I made to check whether there are any included rules that are already included in the externally imported rule-set (like
flutter_lints
andlints
), since there was a lot of overlap with these currently.The full list of rules can be seen here, if there are any additional rules that people would like to include: https://dart-lang.github.io/linter/lints/options/options.html
Since it can be a bit hard to see which rules that are actually included without going to the imported analysis files, this is a full list of the rules that would be in effect when using this package: