You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 16, 2023. It is now read-only.
* feat: ignore `hcwidget` annotations in ['avoid-returning-widgets'](https://dartcodemetrics.dev/docs/rules/common/avoid-returning-widgets) rule by default.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,9 +19,10 @@ PR titles should follow the format below:
19
19
To create a new rule:
20
20
21
21
1. Choose a rule name according to our naming guide or take it from existing issue for the rule.
22
-
2. Add an `.md` file with the rule documentation to `website/docs/rules`. If the rule supports configuration add  badge, if it has auto-fixes add  badge
23
-
3. Create a rule `.dart` file under `lib/src/analyzers/lint_analyzer/rules/rules_list`.
24
-
4. Create a class that extends an abstract rule class depending on your rule type. Available classes: `FlutterRule`, `CommonRule`, `IntlRule`, `AngularRule`. Add a public field with rule id, documentation url.
22
+
2. Add an `.md` file with the rule documentation to `website/docs/rules`. If the rule supports configuration add  badge, if it has auto-fixes add  badge.
23
+
3. Add rule entry into rule index file `website/docs/rules/index.mdx`.
24
+
4. Create a rule `.dart` file under `lib/src/analyzers/lint_analyzer/rules/rules_list`.
25
+
5. Create a class that extends an abstract rule class depending on your rule type. Available classes: `FlutterRule`, `CommonRule`, `IntlRule`, `AngularRule`. Add a public field with rule id, documentation url.
25
26
26
27
The class constructor should take `Map<String, Object> config` parameter which represents config that is passed to the rule from the `analysis_options.yaml`. Example:
27
28
@@ -35,10 +36,10 @@ To create a new rule:
35
36
);
36
37
```
37
38
38
-
5. Add a visitor class which extends any of the base visitors. Usually you will need `RecursiveAstVisitor`. All visitors are [listed there](https://github.com/dart-lang/sdk/blob/master/pkg/analyzer/lib/dart/ast/visitor.dart). Visitor should be added to a separate file and imported with `part` directive.
39
-
6. Add methods overrides to the visitor class for nodes that you want to check (ex. `visitBinaryExpression`, `visitBlock`).
40
-
7. Collect all data needed for the rule (we usually use a private field for data storage and public getter to access it from the `check` method).
41
-
8. In the rule class add override to `check` method. Create a visitor instance and visit all compilation unit children with it.
39
+
6. Add a visitor class which extends any of the base visitors. Usually you will need `RecursiveAstVisitor`. All visitors are [listed there](https://github.com/dart-lang/sdk/blob/master/pkg/analyzer/lib/dart/ast/visitor.dart). Visitor should be added to a separate file and imported with `part` directive.
40
+
7. Add methods overrides to the visitor class for nodes that you want to check (ex. `visitBinaryExpression`, `visitBlock`).
41
+
8. Collect all data needed for the rule (we usually use a private field for data storage and public getter to access it from the `check` method).
42
+
9. In the rule class add override to `check` method. Create a visitor instance and visit all compilation unit children with it.
42
43
43
44
Convert data to `Issue`'s and return them from the method. Example:
44
45
@@ -63,7 +64,8 @@ To create a new rule:
63
64
}
64
65
```
65
66
66
-
9. Add the rule to the `lib/src/analyzers/lint_analyzer/rules/rules_factory.dart`. Example:
67
+
> Override `toJson` method if the rule is configurable.
68
+
10. Add the rule to the `lib/src/analyzers/lint_analyzer/rules/rules_factory.dart`. Example:
67
69
68
70
```dart
69
71
final _implementedRules = <String, Rule Function(Map<String, Object>)>{
@@ -74,7 +76,8 @@ To create a new rule:
74
76
}
75
77
```
76
78
77
-
10. Add the rule tests under `test/analyzers/lint_analyzer/rules/rules_list/`. Prefer to split test examples to a correct/incorrect groups.
79
+
11. Add the rule tests under `test/analyzers/lint_analyzer/rules/rules_list/`. Prefer to split test examples to a correct/incorrect groups.
80
+
12. Add rule into appropriate presets file: `lib/presets/dart_all.yaml` or `lib/presets/flutter_all.yaml`.
0 commit comments