Skip to content

Commit 9727aad

Browse files
authored
Add new lints (#989)
Closes #954 Closes #978 Bump to SDK 3.12.0 to restrict to versions including the new lints. core: - switch_on_type recommended: - simple_directive_paths - simplify_variable_pattern - unnecessary_unawaited
1 parent 773de9d commit 9727aad

6 files changed

Lines changed: 100 additions & 10 deletions

File tree

‎pkgs/lints/CHANGELOG.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
## 6.1.1-wip
1+
## 7.0.0-wip
2+
3+
- `core`:
4+
- added [switch_on_type] (https://github.com/dart-lang/core/issues/954)
5+
- `recommended`:
6+
- added [simple_directive_paths] (https://github.com/dart-lang/core/issues/978)
7+
- added [simplify_variable_pattern] (https://github.com/dart-lang/core/issues/954)
8+
- added [unnecessary_unawaited] (https://github.com/dart-lang/core/issues/954)
9+
10+
[switch_on_type]: https://dart.dev/lints/switch_on_type
11+
[simple_directive_paths]: https://dart.dev/lints/simple_directive_paths
12+
[simplify_variable_pattern]: https://dart.dev/lints/simplify_variable_pattern
13+
[unnecessary_unawaited]: https://dart.dev/lints/unnecessary_unawaited
214

315
## 6.1.0
416

‎pkgs/lints/lib/core.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ linter:
3434
- provide_deprecation_message
3535
- secure_pubspec_urls
3636
- strict_top_level_inference
37+
- switch_on_type
3738
- type_literal_in_constant_pattern
3839
- unintended_html_in_doc_comment
3940
- unnecessary_overrides

‎pkgs/lints/lib/recommended.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ linter:
4747
- prefer_null_aware_operators
4848
- prefer_spread_collections
4949
- recursive_getters
50+
- simple_directive_paths
51+
- simplify_variable_pattern
5052
- slash_for_doc_comments
5153
- type_init_formals
5254
- unnecessary_brace_in_string_interps
@@ -63,6 +65,7 @@ linter:
6365
- unnecessary_string_interpolations
6466
- unnecessary_this
6567
- unnecessary_to_list_in_spreads
68+
- unnecessary_unawaited
6669
- unnecessary_underscores
6770
- use_function_type_syntax_for_parameters
6871
- use_null_aware_elements

‎pkgs/lints/pubspec.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: lints
2-
version: 6.1.1-wip
2+
version: 7.0.0-wip
33
description: >
44
Official Dart lint rules. Defines the 'core' and 'recommended' set of lints
55
suggested by the Dart team.
@@ -11,7 +11,7 @@ topics:
1111
- lints
1212

1313
environment:
14-
sdk: ^3.8.0
14+
sdk: ^3.12.0
1515

1616
# NOTE: Code is not allowed in this package - do not add dependencies.
1717
# dependencies:

‎pkgs/lints/rules.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
| [`provide_deprecation_message`](https://dart.dev/lints/provide_deprecation_message) | Provide a deprecation message, via `@Deprecated("message")`. | |
3434
| [`secure_pubspec_urls`](https://dart.dev/lints/secure_pubspec_urls) | Use secure urls in `pubspec.yaml`. | |
3535
| [`strict_top_level_inference`](https://dart.dev/lints/strict_top_level_inference) | Specify type annotations. | ✅ |
36+
| [`switch_on_type`](https://dart.dev/lints/switch_on_type) | Avoid switch statements on a 'Type'. | |
3637
| [`type_literal_in_constant_pattern`](https://dart.dev/lints/type_literal_in_constant_pattern) | Don't use constant patterns with type literals. | ✅ |
3738
| [`unintended_html_in_doc_comment`](https://dart.dev/lints/unintended_html_in_doc_comment) | Use of angle brackets in a doc comment is treated as HTML by Markdown. | |
3839
| [`unnecessary_overrides`](https://dart.dev/lints/unnecessary_overrides) | Don't override a method to do a super method invocation with the same parameters. | ✅ |
39-
| [`unrelated_type_equality_checks`](https://dart.dev/lints/unrelated_type_equality_checks) | Equality operator `==` invocation with references of unrelated types. | |
40+
| [`unrelated_type_equality_checks`](https://dart.dev/lints/unrelated_type_equality_checks) | Equality operator `==` invocation with references of unrelated types. | ✅ |
4041
| [`use_string_in_part_of_directives`](https://dart.dev/lints/use_string_in_part_of_directives) | Use string in part of directives. | ✅ |
4142
| [`valid_regexps`](https://dart.dev/lints/valid_regexps) | Use valid regular expression syntax. | |
4243
| [`void_checks`](https://dart.dev/lints/void_checks) | Don't assign to `void`. | |
@@ -83,6 +84,8 @@
8384
| [`prefer_null_aware_operators`](https://dart.dev/lints/prefer_null_aware_operators) | Prefer using `null`-aware operators. | ✅ |
8485
| [`prefer_spread_collections`](https://dart.dev/lints/prefer_spread_collections) | Use spread collections when possible. | ✅ |
8586
| [`recursive_getters`](https://dart.dev/lints/recursive_getters) | Property getter recursively returns itself. | |
87+
| [`simple_directive_paths`](https://dart.dev/lints/simple_directive_paths) | Use simple directive paths. | ✅ |
88+
| [`simplify_variable_pattern`](https://dart.dev/lints/simplify_variable_pattern) | Avoid unnecessary member names in variable patterns. | ✅ |
8689
| [`slash_for_doc_comments`](https://dart.dev/lints/slash_for_doc_comments) | Prefer using `///` for doc comments. | ✅ |
8790
| [`type_init_formals`](https://dart.dev/lints/type_init_formals) | Don't type annotate initializing formals. | ✅ |
8891
| [`unnecessary_brace_in_string_interps`](https://dart.dev/lints/unnecessary_brace_in_string_interps) | Avoid using braces in interpolation when not needed. | ✅ |
@@ -99,6 +102,7 @@
99102
| [`unnecessary_string_interpolations`](https://dart.dev/lints/unnecessary_string_interpolations) | Unnecessary string interpolation. | ✅ |
100103
| [`unnecessary_this`](https://dart.dev/lints/unnecessary_this) | Don't access members with `this` unless avoiding shadowing. | ✅ |
101104
| [`unnecessary_to_list_in_spreads`](https://dart.dev/lints/unnecessary_to_list_in_spreads) | Unnecessary `toList()` in spreads. | ✅ |
105+
| [`unnecessary_unawaited`](https://dart.dev/lints/unnecessary_unawaited) | Unnecessary use of 'unawaited'. | ✅ |
102106
| [`unnecessary_underscores`](https://dart.dev/lints/unnecessary_underscores) | Unnecessary underscores can be removed. | ✅ |
103107
| [`use_function_type_syntax_for_parameters`](https://dart.dev/lints/use_function_type_syntax_for_parameters) | Use generic function type syntax for parameters. | ✅ |
104108
| [`use_null_aware_elements`](https://dart.dev/lints/use_null_aware_elements) | If-elements testing for null can be replaced with null-aware elements. | ✅ |

‎pkgs/lints/tool/rules.json‎

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
"description": "Annotate redeclared members.",
4040
"fixStatus": "hasFix"
4141
},
42+
{
43+
"name": "async_return_with_no_await",
44+
"description": "Return with no await.",
45+
"fixStatus": "hasFix"
46+
},
4247
{
4348
"name": "avoid_annotating_with_dynamic",
4449
"description": "Avoid annotating with `dynamic` when not required.",
@@ -102,7 +107,7 @@
102107
{
103108
"name": "avoid_final_parameters",
104109
"description": "Avoid `final` for parameter declarations.",
105-
"fixStatus": "needsFix"
110+
"fixStatus": "hasFix"
106111
},
107112
{
108113
"name": "avoid_function_literals_in_foreach_calls",
@@ -379,6 +384,11 @@
379384
"description": "Use `;` instead of `{}` for empty constructor bodies.",
380385
"fixStatus": "hasFix"
381386
},
387+
{
388+
"name": "empty_container_bodies",
389+
"description": "Use `;` instead of `{}` for empty container bodies.",
390+
"fixStatus": "hasFix"
391+
},
382392
{
383393
"name": "empty_statements",
384394
"description": "Avoid empty statements.",
@@ -409,6 +419,11 @@
409419
"description": "Use Flutter TODO format: // TODO(username): message, https://URL-to-issue.",
410420
"fixStatus": "hasFix"
411421
},
422+
{
423+
"name": "future_sync_value",
424+
"description": "For synchronous values, `Future.syncValue` is more performant.",
425+
"fixStatus": "hasFix"
426+
},
412427
{
413428
"name": "hash_and_equals",
414429
"description": "Always override `hashCode` if overriding `==`.",
@@ -429,14 +444,19 @@
429444
"description": "Don't implicitly reopen classes.",
430445
"fixStatus": "hasFix"
431446
},
447+
{
448+
"name": "initialize_in_field_declaration",
449+
"description": "Initialize the field in the field's initializer.",
450+
"fixStatus": "hasFix"
451+
},
432452
{
433453
"name": "invalid_case_patterns",
434454
"description": "Use case expressions that are valid in Dart 3.0.",
435455
"fixStatus": "hasFix"
436456
},
437457
{
438458
"name": "invalid_runtime_check_with_js_interop_types",
439-
"description": "Avoid runtime type tests with JS interop types where the result may not\n be platform-consistent.",
459+
"description": "Avoid runtime type tests with JS interop types where the result may not be platform-consistent.",
440460
"fixStatus": "needsEvaluation"
441461
},
442462
{
@@ -499,6 +519,11 @@
499519
"description": "Use matching super parameter names.",
500520
"fixStatus": "needsFix"
501521
},
522+
{
523+
"name": "migrate_design_widgets",
524+
"description": "Design widgets should be imported from Material or Cupertino packages.",
525+
"fixStatus": "hasFix"
526+
},
502527
{
503528
"name": "missing_code_block_language_in_doc_comment",
504529
"description": "A code block is missing a specified language.",
@@ -524,6 +549,11 @@
524549
"description": "Don't use more than one case with same value.",
525550
"fixStatus": "hasFix"
526551
},
552+
{
553+
"name": "no_dynamic_casts",
554+
"description": "Avoid implicit casts from `dynamic`.",
555+
"fixStatus": "needsFix"
556+
},
527557
{
528558
"name": "no_leading_underscores_for_library_prefixes",
529559
"description": "Avoid leading underscores for library prefixes.",
@@ -545,7 +575,12 @@
545575
"fixStatus": "noFix"
546576
},
547577
{
548-
"name": "no_runtimeType_toString",
578+
"name": "no_raw_types",
579+
"description": "Avoid raw types.",
580+
"fixStatus": "needsFix"
581+
},
582+
{
583+
"name": "no_runtimetype_tostring",
549584
"description": "Avoid calling `toString()` on `runtimeType`.",
550585
"fixStatus": "noFix"
551586
},
@@ -864,6 +899,11 @@
864899
"description": "Use secure urls in `pubspec.yaml`.",
865900
"fixStatus": "noFix"
866901
},
902+
{
903+
"name": "simple_directive_paths",
904+
"description": "Use simple directive paths.",
905+
"fixStatus": "hasFix"
906+
},
867907
{
868908
"name": "simplify_variable_pattern",
869909
"description": "Avoid unnecessary member names in variable patterns.",
@@ -897,7 +937,7 @@
897937
{
898938
"name": "sort_pub_dependencies",
899939
"description": "Sort pub dependencies alphabetically.",
900-
"fixStatus": "needsFix"
940+
"fixStatus": "hasFix"
901941
},
902942
{
903943
"name": "sort_unnamed_constructors_first",
@@ -994,6 +1034,11 @@
9941034
"description": "Avoid `const` keyword.",
9951035
"fixStatus": "hasFix"
9961036
},
1037+
{
1038+
"name": "unnecessary_const_in_enum_constructor",
1039+
"description": "Don't use an explicit `const` in a generative enum constructor.",
1040+
"fixStatus": "hasFix"
1041+
},
9971042
{
9981043
"name": "unnecessary_constructor_name",
9991044
"description": "Unnecessary `.new` constructor name.",
@@ -1047,7 +1092,7 @@
10471092
{
10481093
"name": "unnecessary_null_aware_operator_on_extension_on_nullable",
10491094
"description": "Unnecessary null aware operator on extension on a nullable type.",
1050-
"fixStatus": "needsFix"
1095+
"fixStatus": "hasFix"
10511096
},
10521097
{
10531098
"name": "unnecessary_null_checks",
@@ -1074,6 +1119,11 @@
10741119
"description": "Unnecessary parentheses can be removed.",
10751120
"fixStatus": "hasFix"
10761121
},
1122+
{
1123+
"name": "unnecessary_primary_constructor_body",
1124+
"description": "Unnecessary primary constructor bodies can be removed.",
1125+
"fixStatus": "hasFix"
1126+
},
10771127
{
10781128
"name": "unnecessary_raw_strings",
10791129
"description": "Unnecessary raw string.",
@@ -1099,11 +1149,21 @@
10991149
"description": "Don't access members with `this` unless avoiding shadowing.",
11001150
"fixStatus": "hasFix"
11011151
},
1152+
{
1153+
"name": "unnecessary_this_alias",
1154+
"description": "Use 'this' directly instead of assigning it to a local variable.",
1155+
"fixStatus": "needsEvaluation"
1156+
},
11021157
{
11031158
"name": "unnecessary_to_list_in_spreads",
11041159
"description": "Unnecessary `toList()` in spreads.",
11051160
"fixStatus": "hasFix"
11061161
},
1162+
{
1163+
"name": "unnecessary_type_name_in_constructor",
1164+
"description": "Don't use an explicit type name in a constructor.",
1165+
"fixStatus": "hasFix"
1166+
},
11071167
{
11081168
"name": "unnecessary_unawaited",
11091169
"description": "Unnecessary use of 'unawaited'.",
@@ -1122,7 +1182,7 @@
11221182
{
11231183
"name": "unrelated_type_equality_checks",
11241184
"description": "Equality operator `==` invocation with references of unrelated types.",
1125-
"fixStatus": "needsEvaluation"
1185+
"fixStatus": "hasFix"
11261186
},
11271187
{
11281188
"name": "unsafe_html",
@@ -1144,6 +1204,11 @@
11441204
"description": "Use `ColoredBox`.",
11451205
"fixStatus": "hasFix"
11461206
},
1207+
{
1208+
"name": "use_declaring_parameters",
1209+
"description": "Use a declaring parameter.",
1210+
"fixStatus": "hasFix"
1211+
},
11471212
{
11481213
"name": "use_decorated_box",
11491214
"description": "Use `DecoratedBox`.",
@@ -1244,6 +1309,11 @@
12441309
"description": "Use valid regular expression syntax.",
12451310
"fixStatus": "noFix"
12461311
},
1312+
{
1313+
"name": "var_with_no_type_annotation",
1314+
"description": "Avoid declaring parameters with `var` and no type annotation.",
1315+
"fixStatus": "hasFix"
1316+
},
12471317
{
12481318
"name": "void_checks",
12491319
"description": "Don't assign to `void`.",

0 commit comments

Comments
 (0)