Skip to content

Commit 20ed966

Browse files
authored
Add use_null_aware_elements to recommended (#923)
Closes #899 Bump to a feature release. Drop an unnecessary `-0` suffix on the SDK constraint. Update URL for reading rules from the dart site source.
1 parent e6c3810 commit 20ed966

File tree

6 files changed

+42
-14
lines changed

6 files changed

+42
-14
lines changed

pkgs/lints/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
## 6.0.1-wip
1+
## 6.1.0-wip
22

3+
- `recommended`:
4+
- added [use_null_aware_elements] (https://github.com/dart-lang/core/issues/899)
35
- Run `dart format` with the new style.
46

7+
[use_null_aware_elements]: https://dart.dev/lints/use_null_aware_elements
8+
59
## 6.0.0
610

711
- `core`:

pkgs/lints/lib/recommended.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ linter:
6565
- unnecessary_to_list_in_spreads
6666
- unnecessary_underscores
6767
- use_function_type_syntax_for_parameters
68+
- use_null_aware_elements
6869
- use_rethrow_when_possible
6970
- use_super_parameters

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.0.1-wip
2+
version: 6.1.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-0
14+
sdk: ^3.8.0
1515

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

pkgs/lints/rules.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| [`avoid_empty_else`](https://dart.dev/lints/avoid_empty_else) | Avoid empty statements in else clauses. ||
99
| [`avoid_relative_lib_imports`](https://dart.dev/lints/avoid_relative_lib_imports) | Avoid relative imports for files in `lib/`. ||
1010
| [`avoid_shadowing_type_parameters`](https://dart.dev/lints/avoid_shadowing_type_parameters) | Avoid shadowing type parameters. | |
11-
| [`avoid_types_as_parameter_names`](https://dart.dev/lints/avoid_types_as_parameter_names) | Avoid types as parameter names. | |
11+
| [`avoid_types_as_parameter_names`](https://dart.dev/lints/avoid_types_as_parameter_names) | Avoid types as parameter names. | |
1212
| [`await_only_futures`](https://dart.dev/lints/await_only_futures) | Await only futures. ||
1313
| [`camel_case_extensions`](https://dart.dev/lints/camel_case_extensions) | Name extensions using UpperCamelCase. | |
1414
| [`camel_case_types`](https://dart.dev/lints/camel_case_types) | Name types using UpperCamelCase. | |
@@ -101,6 +101,7 @@
101101
| [`unnecessary_to_list_in_spreads`](https://dart.dev/lints/unnecessary_to_list_in_spreads) | Unnecessary `toList()` in spreads. ||
102102
| [`unnecessary_underscores`](https://dart.dev/lints/unnecessary_underscores) | Unnecessary underscores can be removed. ||
103103
| [`use_function_type_syntax_for_parameters`](https://dart.dev/lints/use_function_type_syntax_for_parameters) | Use generic function type syntax for parameters. ||
104+
| [`use_null_aware_elements`](https://dart.dev/lints/use_null_aware_elements) | If-elements testing for null can be replaced with null-aware elements. ||
104105
| [`use_rethrow_when_possible`](https://dart.dev/lints/use_rethrow_when_possible) | Use rethrow to rethrow a caught exception. ||
105106
| [`use_super_parameters`](https://dart.dev/lints/use_super_parameters) | Use super-initializer parameters where possible. ||
106107
<!-- recommended -->

pkgs/lints/tool/gen_docs.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import 'package:yaml/yaml.dart' as yaml;
1010
import 'package:http/http.dart' as http;
1111

1212
/// Source of truth for linter rules.
13-
const rulesUrl =
14-
'https://raw.githubusercontent.com/dart-lang/site-www/main/src/_data/linter_rules.json';
13+
final rulesUri = Uri.https(
14+
'raw.githubusercontent.com',
15+
'dart-lang/site-www/main/src/data/linter_rules.json',
16+
);
1517

1618
/// Local cache of linter rules from [rulesUrl].
1719
///
@@ -25,7 +27,7 @@ const rulesMarkdownFilePath = 'rules.md';
2527

2628
/// Fetches the [rulesUrl] JSON description of all lints, saves a cached
2729
/// summary of the relevant fields in [rulesCacheFilePath], and
28-
/// updates [rulesMarkdownFilePath] to
30+
/// updates [rulesMarkdownFilePath].
2931
///
3032
/// Passing any command line argument disables generating documentation,
3133
/// and makes this tool just verify that the doc is up-to-date with the
@@ -91,7 +93,7 @@ Future<Map<String, Map<String, String>>> _fetchRulesJson({
9193
final rulesJsonText = rulesJsonFile.readAsStringSync();
9294
return _readJson(rulesJsonText);
9395
}
94-
final rulesJsonText = (await http.get(Uri.parse(rulesUrl))).body;
96+
final rulesJsonText = (await http.get(rulesUri)).body;
9597
final rulesJson = _readJson(rulesJsonText);
9698

9799
// Re-save [rulesJsonFile] file.

pkgs/lints/tool/rules.json

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
{
5353
"name": "avoid_bool_literals_in_conditional_expressions",
5454
"description": "Avoid `bool` literals in conditional expressions.",
55-
"fixStatus": "needsFix"
55+
"fixStatus": "hasFix"
5656
},
5757
{
5858
"name": "avoid_catches_without_on_clauses",
@@ -222,7 +222,7 @@
222222
{
223223
"name": "avoid_types_as_parameter_names",
224224
"description": "Avoid types as parameter names.",
225-
"fixStatus": "hasFix"
225+
"fixStatus": "noFix"
226226
},
227227
{
228228
"name": "avoid_types_on_closure_parameters",
@@ -356,7 +356,7 @@
356356
},
357357
{
358358
"name": "discarded_futures",
359-
"description": "Don't invoke asynchronous functions in non-`async` blocks.",
359+
"description": "There should be no `Future`-returning calls in synchronous functions unless they are assigned or returned.",
360360
"fixStatus": "hasFix"
361361
},
362362
{
@@ -732,7 +732,7 @@
732732
{
733733
"name": "prefer_foreach",
734734
"description": "Use `forEach` to only apply a function to all the elements.",
735-
"fixStatus": "needsFix"
735+
"fixStatus": "hasFix"
736736
},
737737
{
738738
"name": "prefer_function_declarations_over_variables",
@@ -849,6 +849,11 @@
849849
"description": "Property getter recursively returns itself.",
850850
"fixStatus": "noFix"
851851
},
852+
{
853+
"name": "remove_deprecations_in_breaking_versions",
854+
"description": "Deprecation in major version.",
855+
"fixStatus": "needsFix"
856+
},
852857
{
853858
"name": "require_trailing_commas",
854859
"description": "Use trailing commas for all parameter lists and argument lists.",
@@ -914,6 +919,11 @@
914919
"description": "Place the `super` call last in a constructor initialization list.",
915920
"fixStatus": "noFix"
916921
},
922+
{
923+
"name": "switch_on_type",
924+
"description": "Avoid switch statements on a 'Type'.",
925+
"fixStatus": "noFix"
926+
},
917927
{
918928
"name": "test_types_in_equals",
919929
"description": "Test type of argument in `operator ==(Object other)`.",
@@ -957,7 +967,7 @@
957967
{
958968
"name": "unnecessary_async",
959969
"description": "No await no async.",
960-
"fixStatus": "needsFix"
970+
"fixStatus": "hasFix"
961971
},
962972
{
963973
"name": "unnecessary_await_in_return",
@@ -1089,6 +1099,11 @@
10891099
"description": "Unnecessary `toList()` in spreads.",
10901100
"fixStatus": "hasFix"
10911101
},
1102+
{
1103+
"name": "unnecessary_unawaited",
1104+
"description": "Unnecessary use of 'unawaited'.",
1105+
"fixStatus": "hasFix"
1106+
},
10921107
{
10931108
"name": "unnecessary_underscores",
10941109
"description": "Unnecessary underscores can be removed.",
@@ -1147,7 +1162,7 @@
11471162
{
11481163
"name": "use_if_null_to_convert_nulls_to_bools",
11491164
"description": "Use `??` operators to convert `null`s to `bool`s.",
1150-
"fixStatus": "needsFix"
1165+
"fixStatus": "hasFix"
11511166
},
11521167
{
11531168
"name": "use_is_even_rather_than_modulo",
@@ -1169,6 +1184,11 @@
11691184
"description": "Use predefined named constants.",
11701185
"fixStatus": "hasFix"
11711186
},
1187+
{
1188+
"name": "use_null_aware_elements",
1189+
"description": "If-elements testing for null can be replaced with null-aware elements.",
1190+
"fixStatus": "hasFix"
1191+
},
11721192
{
11731193
"name": "use_raw_strings",
11741194
"description": "Use raw string to avoid escapes.",

0 commit comments

Comments
 (0)