Skip to content

Commit 4c17297

Browse files
authored
Update diagnostic docs for March updates (#6508)
These changes were already reviewed within the SDK.
1 parent 725fff9 commit 4c17297

File tree

2 files changed

+1029
-172
lines changed

2 files changed

+1029
-172
lines changed

src/_data/linter_rules.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@
11851185
"incompatible": [],
11861186
"sets": [],
11871187
"fixStatus": "hasFix",
1188-
"details": "**DO** use Flutter TODO format.\n\nFrom the [Flutter\ndocs](https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-checking-in-comments-that-ask-questions):\n\n> TODOs should include the string TODO in all caps, followed by the GitHub\nusername of the person with the best context about the problem referenced by the\nTODO in parenthesis. A TODO is not a commitment that the person referenced will\nfix the problem, it is intended to be the person with enough context to explain\nthe problem. Thus, when you create a TODO, it is almost always your username\nthat is given.\n\n**GOOD:**\n```dart\n// TODO(username): message.\n// TODO(username): message, https://URL-to-issue.\n```",
1188+
"details": "**DO** use Flutter TODO format.\n\nFrom the [Flutter\ndocs](https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#comments):\n\n> TODOs should include the string TODO in all caps, followed by the GitHub\nusername of the person with the best context about the problem referenced by the\nTODO in parenthesis. A TODO is not a commitment that the person referenced will\nfix the problem, it is intended to be the person with enough context to explain\nthe problem. Thus, when you create a TODO, it is almost always your username\nthat is given.\n\n**GOOD:**\n```dart\n// TODO(username): message.\n// TODO(username): message, https://URL-to-issue.\n```",
11891189
"sinceDartSdk": "2.1"
11901190
},
11911191
{
@@ -2664,7 +2664,11 @@
26642664
],
26652665
"state": "stable",
26662666
"incompatible": [],
2667-
"sets": [],
2667+
"sets": [
2668+
"core",
2669+
"recommended",
2670+
"flutter"
2671+
],
26682672
"fixStatus": "hasFix",
26692673
"details": "Do type annotate top-level and class-like member declarations, where types\nare not inferred from super-interfaces or initializers.\n\nThe lint warns about every omitted return type, parameter type, and\nvariable type of a top-level declaration or class-like-namespace-level\ndeclaration (static or instance member or constructor declaration), which\nis not given a type by inference, and which therefore defaults to dynamic.\n\nThe only omitted types that can be given a type by top-level inference,\nare those of variable declarations with initializer expressions, and\nreturn and parameter types of instance members that override a consistent\ncombined super-interface signature.\n\nSetters do not need a return type, as it is always assumed to be `void`.\n\n**BAD:**\n```dart\nvar _zeroPointCache;\nclass Point {\n get zero => ...;\n final x, y;\n Point(x, y) {}\n closest(b, c) => distance(b) <= distance(c) ? b : c;\n distance(other) => ...;\n}\n_sq(v) => v * v;\n```\n\n**GOOD:**\n```dart\nPoint? _zeroPointCache;\nclass Point {\n Point get zero => ...;\n final int x, y;\n Point(int x, int y) {}\n closest(Point b, Point c) =>\n distance(b) <= distance(c) ? b : c;\n distance(Point other) => ...;\n}\nint _sq(int v) => v * v;\n```",
26702674
"sinceDartSdk": "3.7"
@@ -2929,7 +2933,7 @@
29292933
"categories": [
29302934
"style"
29312935
],
2932-
"state": "experimental",
2936+
"state": "stable",
29332937
"incompatible": [],
29342938
"sets": [],
29352939
"fixStatus": "hasFix",
@@ -3449,6 +3453,20 @@
34493453
"details": "Where possible, use already defined const values.\n\n**BAD:**\n```dart\nconst Duration(seconds: 0);\n```\n\n**GOOD:**\n```dart\nDuration.zero;\n```",
34503454
"sinceDartSdk": "2.13"
34513455
},
3456+
{
3457+
"name": "use_null_aware_elements",
3458+
"description": "If-elements testing for null can be replaced with null-aware elements.",
3459+
"categories": [
3460+
"brevity",
3461+
"style"
3462+
],
3463+
"state": "stable",
3464+
"incompatible": [],
3465+
"sets": [],
3466+
"fixStatus": "hasFix",
3467+
"details": "Where possible, use null-aware elements in collection literals.\n\n**BAD:**\n```dart\nf(String? key) => {if (key != null) key: \"value\"};\n```\n\n**GOOD:**\n```dart\nf(String? key) => {?key: \"value\"};\n```",
3468+
"sinceDartSdk": "3.8"
3469+
},
34523470
{
34533471
"name": "use_raw_strings",
34543472
"description": "Use raw string to avoid escapes.",

0 commit comments

Comments
 (0)