Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(871)

Side by Side Diff: doc/WritingLints.MD

Issue 2340053003: Doc cleanup. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « doc/RELEASING.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ## Writing Lints 1 # Writing Lints
2 2
3 Preliminary notes on writing lints. 3 Preliminary notes on writing lints.
4 4
5 ## Lint Criteria 5 ## Lint Criteria
6 6
7 Borrowing heavily from the criteria for [adding new checks to errorprone] 7 Borrowing heavily from the criteria for [adding new checks to errorprone](https: //github.com/google/error-prone/wiki/Criteria-for-new-checks),
8 (https://github.com/google/error-prone/wiki/Criteria-for-new-checks), lints shou ld have the following properties. 8 lints should have the following properties.
9 9
10 Dart lints: 10 Dart lints:
11 11
12 * should be easy to understand. The problem should be obvious once the linter po ints it out. 12 * should be easy to understand. The problem should be obvious once the linter po ints it out.
13 * should have a correspondingly easy fix. For example, "Remove this type annotat ion", or "Delete these braces", not 13 * should have a correspondingly easy fix. For example, "Remove this type annotat ion", or "Delete these braces", not
14 "Introduce a new subclass and override methods A, B, and C." 14 "Introduce a new subclass and override methods A, B, and C."
15 * should have *few* false positives. 15 * should have *few* false positives.
16 16
17 ## Lint Properties 17 ## Lint Properties
18 18
19 Every lint has a: 19 Every lint has a:
20 20
21 **Description.** A short description of the lint, suitable for printing in conso le output. For example: 21 **Description.** A short description of the lint, suitable for printing in conso le output. For example:
22 22
23 ``` 23 ```
24 [lint] DO name types using UpperCamelCase. 24 [lint] DO name types using UpperCamelCase.
25 ``` 25 ```
26 26
27 **Kind.** The first word in the description should identify the *kind* of lint w here kinds are derived from the 27 **Kind.** The first word in the description should identify the *kind* of lint w here kinds are derived from the
28 [style guide](https://www.dartlang.org/articles/style-guide/). In summary: 28 [style guide](https://www.dartlang.org/articles/style-guide/). In summary:
29 29
30 * ***DO*** guidelines describe practices that should always be followed. There will almost never be a valid reason 30 * ***DO*** guidelines describe practices that should always be followed. There w ill almost never be a valid reason
31 to stray from them. 31 to stray from them.
32 32
33 * ***DON'T*** guidelines are the converse: things that are almost never a good idea. You'll note there are few of 33 * ***DON'T*** guidelines are the converse: things that are almost never a good i dea. You'll note there are few of
34 these here. Guidelines like these in other languages help to avoid the pitfalls that appear over time. Dart is 34 these here. Guidelines like these in other languages help to avoid the pitfalls that appear over time. Dart is
35 new enough that we can just fix those pitfalls directly instead of putting up ro pes around them. 35 new enough that we can just fix those pitfalls directly instead of putting up ro pes around them.
36 36
37 * ***PREFER*** guidelines are practices that you should follow. However, there may be circumstances where it makes 37 * ***PREFER*** guidelines are practices that you should follow. However, there m ay be circumstances where it makes
38 sense to do otherwise. Just make sure you understand the full implications of ig noring the guideline when you do. 38 sense to do otherwise. Just make sure you understand the full implications of ig noring the guideline when you do.
39 39
40 * ***AVOID*** guidelines are the dual to "prefer": stuff you shouldn't do but w here there may be good reasons to 40 * ***AVOID*** guidelines are the dual to "prefer": stuff you shouldn't do but wh ere there may be good reasons to
41 on rare occasions. 41 on rare occasions.
42 42
43 * ***CONSIDER*** guidelines are practices that you might or might not want to f ollow, depending on circumstances, 43 * ***CONSIDER*** guidelines are practices that you might or might not want to fo llow, depending on circumstances,
44 precedents, and your own preference. 44 precedents, and your own preference.
45 45
46 **Detailed Description.** In addition to the short description, a lint rule shou ld have more detailed rationale 46 **Detailed Description.** In addition to the short description, a lint rule shou ld have more detailed rationale
47 with code examples, ideally *good* and *bad*. The [style guide](https://www.dart lang.org/articles/style-guide/) is 47 with code examples, ideally *good* and *bad*. The [style guide](https://www.dart lang.org/articles/style-guide/) is
48 a great source for inspiration. Many style recommendations have been directly t ranslated to lints as enumerated 48 a great source for inspiration. Many style recommendations have been directly t ranslated to lints as enumerated
49 [here](http://dart-lang.github.io/linter/lints/). 49 [here](http://dart-lang.github.io/linter/lints/).
50 50
51 **Group.** A grouping. For example, *Style Guide* aggregates style guide deriv ed lints. 51 **Group.** A grouping. For example, *Style Guide* aggregates style guide deriv ed lints.
52 52
53 **Maturity.** Rules can be further distinguished by maturity. Unqualified rules are considered stable, 53 **Maturity.** Rules can be further distinguished by maturity. Unqualified rules are considered stable,
54 while others may be marked *EXPERIMENTAL* or *PROPOSED* to indicate that they ar e under review. 54 while others may be marked *EXPERIMENTAL* or *PROPOSED* to indicate that they ar e under review.
55 55
56 ## Mechanics 56 ## Mechanics
57 57
58 Lints live in the [lib/src/rules](https://github.com/dart-lang/linter/tree/maste r/lib/src/rules) directory. 58 Lints live in the [lib/src/rules](https://github.com/dart-lang/linter/tree/maste r/lib/src/rules) directory.
59 Corresponding tests live in [test/rules](https://github.com/dart-lang/linter/tre e/master/test/rules). 59 Corresponding tests live in [test/rules](https://github.com/dart-lang/linter/tre e/master/test/rules).
60 60
61 Rule stubs can be generated with the [rule.dart](https://github.com/dart-lang/li nter/blob/master/tool/rule.dart) 61 Rule stubs can be generated with the [rule.dart](https://github.com/dart-lang/li nter/blob/master/tool/rule.dart)
62 helper script and documentation gets generated with [doc.dart] 62 helper script and documentation gets generated with [doc.dart](https://github.co m/dart-lang/linter/blob/master/tool/doc.dart).
63 (https://github.com/dart-lang/linter/blob/master/tool/doc.dart). 63 Helper scripts can be invoked via `dart` or grinder (`pub run grinder docs:doc_l ocation` and `pub run grinder rule:my_new_rule` respectively).
64 64
65 Needless to say, details are under active development. Feedback is most [welcom e](https://github.com/dart-lang/linter/issues)! 65 Needless to say, details are under active development. Feedback is most [welcom e](https://github.com/dart-lang/linter/issues)!
OLDNEW
« no previous file with comments | « doc/RELEASING.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698