Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkgs/lints/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## 6.0.1-wip
## 6.1.0-wip

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

[use_null_aware_elements]: https://dart.dev/lints/use_null_aware_elements

## 6.0.0

- `core`:
Expand Down
1 change: 1 addition & 0 deletions pkgs/lints/lib/recommended.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ linter:
- unnecessary_to_list_in_spreads
- unnecessary_underscores
- use_function_type_syntax_for_parameters
- use_null_aware_elements
- use_rethrow_when_possible
- use_super_parameters
4 changes: 2 additions & 2 deletions pkgs/lints/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: lints
version: 6.0.1-wip
version: 6.1.0-wip
description: >
Official Dart lint rules. Defines the 'core' and 'recommended' set of lints
suggested by the Dart team.
Expand All @@ -11,7 +11,7 @@ topics:
- lints

environment:
sdk: ^3.8.0-0
sdk: ^3.8.0

# NOTE: Code is not allowed in this package - do not add dependencies.
# dependencies:
Expand Down
3 changes: 2 additions & 1 deletion pkgs/lints/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| [`avoid_empty_else`](https://dart.dev/lints/avoid_empty_else) | Avoid empty statements in else clauses. | ✅ |
| [`avoid_relative_lib_imports`](https://dart.dev/lints/avoid_relative_lib_imports) | Avoid relative imports for files in `lib/`. | ✅ |
| [`avoid_shadowing_type_parameters`](https://dart.dev/lints/avoid_shadowing_type_parameters) | Avoid shadowing type parameters. | |
| [`avoid_types_as_parameter_names`](https://dart.dev/lints/avoid_types_as_parameter_names) | Avoid types as parameter names. | |
| [`avoid_types_as_parameter_names`](https://dart.dev/lints/avoid_types_as_parameter_names) | Avoid types as parameter names. | |
| [`await_only_futures`](https://dart.dev/lints/await_only_futures) | Await only futures. | ✅ |
| [`camel_case_extensions`](https://dart.dev/lints/camel_case_extensions) | Name extensions using UpperCamelCase. | |
| [`camel_case_types`](https://dart.dev/lints/camel_case_types) | Name types using UpperCamelCase. | |
Expand Down Expand Up @@ -101,6 +101,7 @@
| [`unnecessary_to_list_in_spreads`](https://dart.dev/lints/unnecessary_to_list_in_spreads) | Unnecessary `toList()` in spreads. | ✅ |
| [`unnecessary_underscores`](https://dart.dev/lints/unnecessary_underscores) | Unnecessary underscores can be removed. | ✅ |
| [`use_function_type_syntax_for_parameters`](https://dart.dev/lints/use_function_type_syntax_for_parameters) | Use generic function type syntax for parameters. | ✅ |
| [`use_null_aware_elements`](https://dart.dev/lints/use_null_aware_elements) | If-elements testing for null can be replaced with null-aware elements. | ✅ |
| [`use_rethrow_when_possible`](https://dart.dev/lints/use_rethrow_when_possible) | Use rethrow to rethrow a caught exception. | ✅ |
| [`use_super_parameters`](https://dart.dev/lints/use_super_parameters) | Use super-initializer parameters where possible. | ✅ |
<!-- recommended -->
Expand Down
10 changes: 6 additions & 4 deletions pkgs/lints/tool/gen_docs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:yaml/yaml.dart' as yaml;
import 'package:http/http.dart' as http;

/// Source of truth for linter rules.
const rulesUrl =
'https://raw.githubusercontent.com/dart-lang/site-www/main/src/_data/linter_rules.json';
final rulesUri = Uri.https(
'raw.githubusercontent.com',
'dart-lang/site-www/main/src/data/linter_rules.json',
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated nit, feel free to ignore, but the comment on line 30 below ends prematurely (or has a hanging "to" that should be deleted).


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

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

// Re-save [rulesJsonFile] file.
Expand Down
32 changes: 26 additions & 6 deletions pkgs/lints/tool/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{
"name": "avoid_bool_literals_in_conditional_expressions",
"description": "Avoid `bool` literals in conditional expressions.",
"fixStatus": "needsFix"
"fixStatus": "hasFix"
},
{
"name": "avoid_catches_without_on_clauses",
Expand Down Expand Up @@ -222,7 +222,7 @@
{
"name": "avoid_types_as_parameter_names",
"description": "Avoid types as parameter names.",
"fixStatus": "hasFix"
"fixStatus": "noFix"
},
{
"name": "avoid_types_on_closure_parameters",
Expand Down Expand Up @@ -356,7 +356,7 @@
},
{
"name": "discarded_futures",
"description": "Don't invoke asynchronous functions in non-`async` blocks.",
"description": "There should be no `Future`-returning calls in synchronous functions unless they are assigned or returned.",
"fixStatus": "hasFix"
},
{
Expand Down Expand Up @@ -732,7 +732,7 @@
{
"name": "prefer_foreach",
"description": "Use `forEach` to only apply a function to all the elements.",
"fixStatus": "needsFix"
"fixStatus": "hasFix"
},
{
"name": "prefer_function_declarations_over_variables",
Expand Down Expand Up @@ -849,6 +849,11 @@
"description": "Property getter recursively returns itself.",
"fixStatus": "noFix"
},
{
"name": "remove_deprecations_in_breaking_versions",
"description": "Deprecation in major version.",
"fixStatus": "needsFix"
},
{
"name": "require_trailing_commas",
"description": "Use trailing commas for all parameter lists and argument lists.",
Expand Down Expand Up @@ -914,6 +919,11 @@
"description": "Place the `super` call last in a constructor initialization list.",
"fixStatus": "noFix"
},
{
"name": "switch_on_type",
"description": "Avoid switch statements on a 'Type'.",
"fixStatus": "noFix"
},
{
"name": "test_types_in_equals",
"description": "Test type of argument in `operator ==(Object other)`.",
Expand Down Expand Up @@ -957,7 +967,7 @@
{
"name": "unnecessary_async",
"description": "No await no async.",
"fixStatus": "needsFix"
"fixStatus": "hasFix"
},
{
"name": "unnecessary_await_in_return",
Expand Down Expand Up @@ -1089,6 +1099,11 @@
"description": "Unnecessary `toList()` in spreads.",
"fixStatus": "hasFix"
},
{
"name": "unnecessary_unawaited",
"description": "Unnecessary use of 'unawaited'.",
"fixStatus": "hasFix"
},
{
"name": "unnecessary_underscores",
"description": "Unnecessary underscores can be removed.",
Expand Down Expand Up @@ -1147,7 +1162,7 @@
{
"name": "use_if_null_to_convert_nulls_to_bools",
"description": "Use `??` operators to convert `null`s to `bool`s.",
"fixStatus": "needsFix"
"fixStatus": "hasFix"
},
{
"name": "use_is_even_rather_than_modulo",
Expand All @@ -1169,6 +1184,11 @@
"description": "Use predefined named constants.",
"fixStatus": "hasFix"
},
{
"name": "use_null_aware_elements",
"description": "If-elements testing for null can be replaced with null-aware elements.",
"fixStatus": "hasFix"
},
{
"name": "use_raw_strings",
"description": "Use raw string to avoid escapes.",
Expand Down