Skip to content

Commit f77a93e

Browse files
committed
Include newest diagnostics and lints
1 parent 6bab186 commit f77a93e

File tree

2 files changed

+114
-39
lines changed

2 files changed

+114
-39
lines changed

src/_data/linter_rules.json

+24-2
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,17 @@
450450
"details": "**AVOID** throwing exceptions in finally blocks.\n\nThrowing exceptions in finally blocks will inevitably cause unexpected behavior\nthat is hard to debug.\n\n**BAD:**\n```dart\nclass BadThrow {\n double nonCompliantMethod() {\n try {\n print('hello world! ${1 / 0}');\n } catch (e) {\n print(e);\n } finally {\n throw 'Find the hidden error :P'; // LINT\n }\n }\n}\n```\n\n**GOOD:**\n```dart\nclass Ok {\n double compliantMethod() {\n var i = 5;\n try {\n i = 1 / 0;\n } catch (e) {\n print(e); // OK\n }\n return i;\n }\n}\n```\n\n",
451451
"sinceDartSdk": "2.0.0"
452452
},
453+
{
454+
"name": "unintended_html_in_doc_comment",
455+
"description": "Use of angle brackets in a doc comment is treated as HTML by Markdown.",
456+
"group": "errors",
457+
"state": "stable",
458+
"incompatible": [],
459+
"sets": [],
460+
"fixStatus": "needsEvaluation",
461+
"details": "**DO** reference only in-scope identifiers in doc comments.\n\nWhen a developer writes a reference with angle brackets within a doc comment,\nthe angle brackets are interpreted as HTML. The text within pairs of opening and\nclosing angle brackets generally get swallowed by the browser, and will not be\ndisplayed.\n\nWrap text with angle brackets within a code block or within a code span, unless\nthey are delimiters for a Markdown autolink. You can also replace `<` with\n`&lt;` and `>` with `&gt;`.\n\n**BAD:**\n```dart\n/// Text List<int>.\n/// Text [List<int>].\n/// <assignment> -> <variable> = <expression>\n```\n\n**GOOD:**\n```dart\n/// Text `List<int>`.\n/// `<assignment> -> <variable> = <expression>`\n/// <http://foo.bar.baz>\n```\n\n",
462+
"sinceDartSdk": "3.4.0-wip"
463+
},
453464
{
454465
"name": "unnecessary_statements",
455466
"description": "Avoid using unnecessary statements.",
@@ -2195,13 +2206,13 @@
21952206
},
21962207
{
21972208
"name": "require_trailing_commas",
2198-
"description": "Use trailing commas for all function calls and declarations.",
2209+
"description": "Use trailing commas for all parameter lists and argument lists.",
21992210
"group": "style",
22002211
"state": "stable",
22012212
"incompatible": [],
22022213
"sets": [],
22032214
"fixStatus": "hasFix",
2204-
"details": "**DO** use trailing commas for all function calls and declarations unless the\nfunction call or definition, from the start of the function name up to the\nclosing parenthesis, fits in a single line.\n\n**BAD:**\n```dart\nvoid run() {\n method('does not fit on one line',\n 'test test test test test test test test test test test');\n}\n```\n\n**GOOD:**\n```dart\nvoid run() {\n method(\n 'does not fit on one line',\n 'test test test test test test test test test test test',\n );\n}\n```\n\n**EXCEPTION:** If the final parameter/argument is positional (vs named) and is\neither a function literal implemented using curly braces, a literal map, a\nliteral set or a literal array. This exception only applies if the final\nparameter does not fit entirely on one line.\n\n**NOTE:** This lint rule assumes `dart format` has been run over the code and\nmay produce false positives until that has happened.\n\n",
2215+
"details": "**DO** use trailing commas for all multi-line parameter lists and argument\nlists. A parameter list or argument list that fits on one line, including the\nopening parenthesis and closing parenthesis, does not require a trailing comma.\n\n**BAD:**\n```dart\nvoid run() {\n method('does not fit on one line',\n 'test test test test test test test test test test test');\n}\n```\n\n**GOOD:**\n```dart\nvoid run() {\n method(\n 'does not fit on one line',\n 'test test test test test test test test test test test',\n );\n}\n```\n\n**EXCEPTION:** If the final argument in an argument list is positional (vs\nnamed) and is either a function literal with curly braces, a map literal, a set\nliteral, or a list literal, then a trailing comma is not required.\nThis exception only applies if the final argument does not fit entirely on one\nline.\n\n**NOTE:** This lint rule assumes that code has been formatted with `dart format`\nand may produce false positives on unformatted code.\n\n",
22052216
"sinceDartSdk": "2.14.0"
22062217
},
22072218
{
@@ -2478,6 +2489,17 @@
24782489
"details": "**DO** use library directives if you want to document a library and/or annotate \na library.\n\n**BAD:**\n```dart\nlibrary;\n```\n\n**GOOD:**\n```dart\n/// This library does important things\nlibrary;\n```\n\n```dart\n@TestOn('js')\nlibrary;\n```\n\nNOTE: Due to limitations with this lint, libraries with parts will not be\nflagged for unnecessary library directives.\n",
24792490
"sinceDartSdk": "2.19.0"
24802491
},
2492+
{
2493+
"name": "unnecessary_library_name",
2494+
"description": "Don't have a library name in a `library` declaration.",
2495+
"group": "style",
2496+
"state": "stable",
2497+
"incompatible": [],
2498+
"sets": [],
2499+
"fixStatus": "hasFix",
2500+
"details": "**DON'T** have a library name in a `library` declaration.\n\nLibrary names are not necessary.\n\nA library does not need a library declaration, but one can be added to attach\nlibrary documentation and library metadata to. A declaration of `library;` is\nsufficient for those uses.\n\nThe only *use* of a library name is for a `part` file to refer back to its\nowning library, but part files should prefer to use a string URI to refer back\nto the library file, not a library name.\n\nIf a library name is added to a library declaration, it introduces the risk of\nname *conflicts*. It's a compile-time error if two libraries in the same program\nhave the same library name. To avoid that, library names tend to be long,\nincluding the package name and path, just to avoid accidental name clashes. That\nmakes such library names hard to read, and not even useful as documentation.\n\n**BAD:**\n```dart\n/// This library has a long name.\nlibrary magnificator.src.helper.bananas;\n```\n\n```dart\nlibrary utils; // Not as verbose, but risks conflicts.\n```\n\n**GOOD:**\n```dart\n/// This library is awesome.\nlibrary;\n\npart \"apart.dart\"; // contains: `part of \"good_library.dart\";`\n```\n",
2501+
"sinceDartSdk": "3.4.0-wip"
2502+
},
24812503
{
24822504
"name": "unnecessary_new",
24832505
"description": "Unnecessary new keyword.",

src/content/tools/diagnostic-messages.md

+90-37
Original file line numberDiff line numberDiff line change
@@ -5341,17 +5341,17 @@ class C {}
53415341

53425342
### enum_constant_same_name_as_enclosing
53435343

5344-
_The name of the enum constant can't be the same as the enum's name._
5344+
_The name of the enum value can't be the same as the enum's name._
53455345

53465346
#### Description
53475347

5348-
The analyzer produces this diagnostic when an enum constant has the same
5349-
name as the enum in which it's declared.
5348+
The analyzer produces this diagnostic when an enum value has the same name
5349+
as the enum in which it's declared.
53505350

53515351
#### Example
53525352

5353-
The following code produces this diagnostic because the enum constant `E`
5354-
has the same name as the enclosing enum `E`:
5353+
The following code produces this diagnostic because the enum value `E` has
5354+
the same name as the enclosing enum `E`:
53555355

53565356
```dart
53575357
enum E {
@@ -5383,14 +5383,14 @@ _The invoked constructor isn't a 'const' constructor._
53835383

53845384
#### Description
53855385

5386-
The analyzer produces this diagnostic when an enum constant is being
5387-
created using either a factory constructor or a generative constructor
5388-
that isn't marked as being `const`.
5386+
The analyzer produces this diagnostic when an enum value is being created
5387+
using either a factory constructor or a generative constructor that isn't
5388+
marked as being `const`.
53895389

53905390
#### Example
53915391

5392-
The following code produces this diagnostic because the enum constant `e`
5393-
is being initialized by a factory constructor:
5392+
The following code produces this diagnostic because the enum value `e` is
5393+
being initialized by a factory constructor:
53945394

53955395
```dart
53965396
enum E {
@@ -5422,8 +5422,8 @@ _Mixins applied to enums can't have instance variables._
54225422

54235423
The analyzer produces this diagnostic when a mixin that's applied to an
54245424
enum declares one or more instance variables. This isn't allowed because
5425-
the enum constants are constant, and there isn't any way for the
5426-
constructor in the enum to initialize any of the mixin's fields.
5425+
the enum values are constant, and there isn't any way for the constructor
5426+
in the enum to initialize any of the mixin's fields.
54275427

54285428
#### Example
54295429

@@ -10959,7 +10959,7 @@ E f() => const [!E!](2);
1095910959

1096010960
#### Common fixes
1096110961

10962-
If there's an enum constant with the same value, or if you add such a
10962+
If there's an enum value with the same value, or if you add such a
1096310963
constant, then reference the constant directly:
1096410964

1096510965
```dart
@@ -11306,6 +11306,59 @@ extension E on String {
1130611306
}
1130711307
```
1130811308

11309+
### invalid_use_of_do_not_submit_member
11310+
11311+
_Uses of '{0}' should not be submitted to source control._
11312+
11313+
#### Description
11314+
11315+
The analyzer produces this diagnostic when a member that is annotated with
11316+
[`@doNotSubmit`][meta-doNotSubmit] is referenced outside of a member
11317+
declaration that is also annotated with `@doNotSubmit`.
11318+
11319+
#### Example
11320+
11321+
Given a file `a.dart` containing the following declaration:
11322+
11323+
```dart
11324+
import 'package:meta/meta.dart';
11325+
11326+
@doNotSubmit
11327+
void emulateCrash() { /* ... */ }
11328+
```
11329+
11330+
The following code produces this diagnostic because the declaration is
11331+
being referenced outside of a member that is also annotated with
11332+
`@doNotSubmit`:
11333+
11334+
```dart
11335+
import 'a.dart';
11336+
11337+
void f() {
11338+
[!emulateCrash!]();
11339+
}
11340+
```
11341+
11342+
#### Common fixes
11343+
11344+
Most commonly, when complete with local testing, the reference to the
11345+
member should be removed.
11346+
11347+
If building additional functionality on top of the member, annotate the
11348+
newly added member with `@doNotSubmit` as well:
11349+
11350+
```dart
11351+
import 'package:meta/meta.dart';
11352+
11353+
import 'a.dart';
11354+
11355+
@doNotSubmit
11356+
void emulateCrashWithOtherFunctionality() {
11357+
emulateCrash();
11358+
// do other things.
11359+
}
11360+
```
11361+
1130911362
### invalid_use_of_internal_member
1131011363

1131111364
_The member '{0}' can only be used within its package._
@@ -12607,7 +12660,7 @@ must be handled.
1260712660

1260812661
#### Example
1260912662

12610-
The following code produces this diagnostic because the enum constant `e2`
12663+
The following code produces this diagnostic because the enum value `e2`
1261112664
isn't handled:
1261212665

1261312666
```dart
@@ -21289,8 +21342,8 @@ _There's no constant named '{0}' in '{1}'._
2128921342

2129021343
#### Description
2129121344

21292-
The analyzer produces this diagnostic when it encounters an identifier that
21293-
appears to be the name of an enum constant, and the name either isn't
21345+
The analyzer produces this diagnostic when it encounters an identifier
21346+
that appears to be the name of an enum value, and the name either isn't
2129421347
defined or isn't visible in the scope in which it's being referenced.
2129521348

2129621349
#### Example
@@ -21333,11 +21386,11 @@ _The enum doesn't have an unnamed constructor._
2133321386
#### Description
2133421387

2133521388
The analyzer produces this diagnostic when the constructor invoked to
21336-
initialize an enum constant doesn't exist.
21389+
initialize an enum value doesn't exist.
2133721390

2133821391
#### Examples
2133921392

21340-
The following code produces this diagnostic because the enum constant `c`
21393+
The following code produces this diagnostic because the enum value `c`
2134121394
is being initialized by the unnamed constructor, but there's no unnamed
2134221395
constructor defined in `E`:
2134321396

@@ -21349,9 +21402,9 @@ enum E {
2134921402
}
2135021403
```
2135121404

21352-
The following code produces this diagnostic because the enum constant `c`
21353-
is being initialized by the constructor named `x`, but there's no
21354-
constructor named `x` defined in `E`:
21405+
The following code produces this diagnostic because the enum value `c` is
21406+
being initialized by the constructor named `x`, but there's no constructor
21407+
named `x` defined in `E`:
2135521408

2135621409
```dart
2135721410
enum E {
@@ -21363,9 +21416,9 @@ enum E {
2136321416

2136421417
#### Common fixes
2136521418

21366-
If the enum constant is being initialized by the unnamed constructor and
21367-
one of the named constructors should have been used, then add the name of
21368-
the constructor:
21419+
If the enum value is being initialized by the unnamed constructor and one
21420+
of the named constructors should have been used, then add the name of the
21421+
constructor:
2136921422

2137021423
```dart
2137121424
enum E {
@@ -21375,8 +21428,8 @@ enum E {
2137521428
}
2137621429
```
2137721430

21378-
If the enum constant is being initialized by the unnamed constructor and
21379-
none of the named constructors are appropriate, then define the unnamed
21431+
If the enum value is being initialized by the unnamed constructor and none
21432+
of the named constructors are appropriate, then define the unnamed
2138021433
constructor:
2138121434

2138221435
```dart
@@ -21387,9 +21440,9 @@ enum E {
2138721440
}
2138821441
```
2138921442

21390-
If the enum constant is being initialized by a named constructor and one
21391-
of the existing constructors should have been used, then change the name
21392-
of the constructor being invoked (or remove it if the unnamed constructor
21443+
If the enum value is being initialized by a named constructor and one of
21444+
the existing constructors should have been used, then change the name of
21445+
the constructor being invoked (or remove it if the unnamed constructor
2139321446
should be used):
2139421447

2139521448
```dart
@@ -21401,9 +21454,9 @@ enum E {
2140121454
}
2140221455
```
2140321456

21404-
If the enum constant is being initialized by a named constructor and none
21405-
of the existing constructors should have been used, then define a
21406-
constructor with the name that was used:
21457+
If the enum value is being initialized by a named constructor and none of
21458+
the existing constructors should have been used, then define a constructor
21459+
with the name that was used:
2140721460

2140821461
```dart
2140921462
enum E {
@@ -23448,7 +23501,7 @@ _A member named 'values' can't be declared in an enum._
2344823501
#### Description
2344923502

2345023503
The analyzer produces this diagnostic when an enum declaration defines a
23451-
member named `values`, whether the member is an enum constant, an instance
23504+
member named `values`, whether the member is an enum value, an instance
2345223505
member, or a static member.
2345323506

2345423507
Any such member conflicts with the implicit declaration of the static
@@ -23721,14 +23774,14 @@ given._
2372123774

2372223775
#### Description
2372323776

23724-
The analyzer produces this diagnostic when an enum constant in an enum
23725-
that has type parameters is instantiated and type arguments are provided,
23726-
but the number of type arguments isn't the same as the number of type
23777+
The analyzer produces this diagnostic when an enum value in an enum that
23778+
has type parameters is instantiated and type arguments are provided, but
23779+
the number of type arguments isn't the same as the number of type
2372723780
parameters.
2372823781

2372923782
#### Example
2373023783

23731-
The following code produces this diagnostic because the enum constant `c`
23784+
The following code produces this diagnostic because the enum value `c`
2373223785
provides one type argument even though the enum `E` is declared to have
2373323786
two type parameters:
2373423787

0 commit comments

Comments
 (0)