Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 79750ea

Browse files
authored
docs: rework website rule page (#959)
1 parent b9d72d9 commit 79750ea

File tree

69 files changed

+670
-1025
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+670
-1025
lines changed

website/docs/rules/angular/avoid-preserve-whitespace-false.md renamed to website/docs/rules/angular/avoid-preserve-whitespace-false.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
# Avoid preserveWhitespace: false
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
## Rule id {#rule-id}
4-
5-
avoid-preserve-whitespace-false
6-
7-
## Severity {#severity}
8-
9-
Warning
10-
11-
## Description {#description}
3+
<RuleDetails version="1.5.1" severity="warning" />
124

135
Avoid setting `preserveWhitespace` in Angular `@Component` annotations to false explicitly. Its default value is already false.
146

157
### Example {#example}
168

17-
Bad:
9+
**Bad:**
1810

1911
```dart
2012
@Component(
@@ -31,7 +23,7 @@ class Component {
3123
}
3224
```
3325

34-
Good:
26+
**Good:**
3527

3628
```dart
3729
@Component(

website/docs/rules/angular/component-annotation-arguments-ordering.md renamed to website/docs/rules/angular/component-annotation-arguments-ordering.mdx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
# Component annotation arguments ordering
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
![Configurable](https://img.shields.io/badge/-configurable-informational)
4-
5-
## Rule id {#rule-id}
6-
7-
component-annotation-arguments-ordering
8-
9-
## Severity {#severity}
10-
11-
Style
12-
13-
## Description {#description}
3+
<RuleDetails version="1.9.0" severity="style" hasConfig />
144

155
Enforces Angular `@Component` annotation arguments ordering.
166

@@ -27,7 +17,7 @@ The value for `order` may be an array consisting of the following strings (defau
2717
- exports
2818
- change-detection
2919

30-
### Config example {#config-example}
20+
### ⚙️ Config example {#config-example}
3121

3222
```yaml
3323
dart_code_metrics:

website/docs/rules/angular/prefer-on-push-cd-strategy.md renamed to website/docs/rules/angular/prefer-on-push-cd-strategy.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
# Prefer using onPush change detection strategy
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
## Rule id {#rule-id}
4-
5-
prefer-on-push-cd-strategy
6-
7-
## Severity {#severity}
8-
9-
Warning
10-
11-
## Description {#description}
3+
<RuleDetails version="1.8.0" severity="warning" />
124

135
Prefer setting `changeDetection: ChangeDetectionStrategy.OnPush` in Angular `@Component` annotations.
146
OnPush strategy should be used as the default because using Default strategy leads to performance issues.
157

168
### Example {#example}
179

18-
Bad:
10+
**Bad:**
1911

2012
```dart
2113
@Component(
@@ -30,7 +22,7 @@ class Component {
3022
}
3123
```
3224

33-
Good:
25+
**Good:**
3426

3527
```dart
3628
@Component(

website/docs/rules/common/avoid-banned-imports.md renamed to website/docs/rules/common/avoid-banned-imports.mdx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
1-
# Avoid banned imports
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
## Rule id {#rule-id}
4-
5-
avoid-banned-imports
6-
7-
## Severity {#severity}
8-
9-
Style
10-
11-
## Description {#description}
3+
<RuleDetails version="4.16.0" severity="style" hasConfig />
124

135
Configure some imports that you want to ban.
146

157
### Example {#example}
168

179
With the configuration in the example below, here are some bad/good examples.
1810

19-
Bad:
11+
**Bad:**
2012

2113
```dart
2214
import "package:flutter/material.dart";
2315
import "package:flutter_bloc/flutter_bloc.dart";
2416
```
2517

26-
Good:
18+
**Good:**
2719

2820
```dart
2921
// No restricted imports in listed folders.
3022
```
3123

32-
### Config example {#config-example}
24+
### ⚙️ Config example {#config-example}
3325

3426
The `paths` and `deny` both support regular expressions.
3527

@@ -38,7 +30,7 @@ dart_code_metrics:
3830
...
3931
rules:
4032
...
41-
- avoid_restricted_imports:
33+
- avoid-banned-imports:
4234
entries:
4335
- paths: ["some/folder/.*\.dart", "another/folder/.*\.dart"]
4436
deny: ["package:flutter/material.dart"]

website/docs/rules/common/avoid-collection-methods-with-unrelated-types.md renamed to website/docs/rules/common/avoid-collection-methods-with-unrelated-types.mdx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
# Avoid collection methods with unrelated types
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
## Rule id {#rule-id}
4-
5-
avoid-collection-methods-with-unrelated-types
6-
7-
## Severity {#severity}
8-
9-
Warning
10-
11-
## Description {#description}
3+
<RuleDetails version="4.14.0" severity="warning" />
124

135
Avoid using collection methods with unrelated types, such as accessing a map of integers using a string key.
146

7+
:::info
8+
159
This lint has been requested for a long time: Follow [this link](https://github.com/dart-lang/linter/issues/1307) to see the details.
1610

1711
Related: Dart's built-in `list_remove_unrelated_type` and `iterable_contains_unrelated_type`.
1812

13+
:::
14+
1915
### Example {#example}
2016

21-
Bad:
17+
**Bad:**
2218

2319
```dart
2420
final map = Map<int, String>();
@@ -43,7 +39,7 @@ set.removeAll(Iterable<String>.empty()); // LINT
4339
set.retainAll(Iterable<String>.empty()); // LINT
4440
```
4541

46-
Good:
42+
**Good:**
4743

4844
```dart
4945
final map = Map<int, String>();

website/docs/rules/common/avoid-duplicate-exports.md renamed to website/docs/rules/common/avoid-duplicate-exports.mdx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
# Avoid duplicate exports
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
## Rule id {#rule-id}
4-
5-
avoid-duplicate-exports
6-
7-
## Severity {#severity}
8-
9-
Warning
10-
11-
## Description {#description}
3+
<RuleDetails version="4.17.0" severity="warning" />
124

135
Warns when a file has multiple `exports` declarations with the same URI.
146

157
### Example {#example}
168

17-
With the configuration in the example below, here are some bad/good examples.
18-
19-
Bad:
9+
**❌ Bad:**
2010

2111
```dart
2212
import "package:flutter/material.dart";
@@ -26,7 +16,7 @@ export 'package:my_app/good_folder/something.dart';
2616
export 'package:my_app/good_folder/something.dart'; // LINT
2717
```
2818

29-
Good:
19+
**Good:**
3020

3121
```dart
3222
import "package:flutter/material.dart";

website/docs/rules/common/avoid-dynamic.md

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import RuleDetails from '@site/src/components/RuleDetails';
2+
3+
<RuleDetails version="4.11.0" severity="warning" />
4+
5+
Warns when the `dynamic` type is used as a variable type in a declaration, return type of a function, etc. Using `dynamic` is considered unsafe since it can easily result in runtime errors.
6+
7+
:::info
8+
9+
Using the `dynamic` type for a `Map<>` is considered fine, since there is no better way to declare a type of a JSON payload.
10+
11+
:::
12+
13+
### Example {#example}
14+
15+
**❌ Bad:**
16+
17+
```dart
18+
dynamic x = 10; // LINT
19+
20+
// LINT
21+
String concat(dynamic a, dynamic b) {
22+
return a + b;
23+
}
24+
```
25+
26+
**✅ Good:**
27+
28+
```dart
29+
int x = 10;
30+
31+
final x = 10;
32+
33+
String concat(String a, String b) {
34+
return a + b;
35+
}
36+
```

website/docs/rules/common/avoid-global-state.md renamed to website/docs/rules/common/avoid-global-state.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
# Avoid global state
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
## Rule id {#rule-id}
4-
5-
avoid-global-state
6-
7-
## Severity {#severity}
8-
9-
Warning
10-
11-
## Description {#description}
3+
<RuleDetails version="4.10.0" severity="warning" />
124

135
The rule should violate on not final and non-const top-level variables.
146

@@ -22,7 +14,7 @@ So the common practice is to use state management solutions instead of mutable g
2214

2315
### Example {#example}
2416

25-
Bad:
17+
**Bad:**
2618

2719
```dart
2820
var answer = 42; // LINT
@@ -33,7 +25,7 @@ class Foo {
3325
}
3426
```
3527

36-
Good:
28+
**Good:**
3729

3830
```dart
3931
const answer = 42;

website/docs/rules/common/avoid-ignoring-return-values.md renamed to website/docs/rules/common/avoid-ignoring-return-values.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1-
# Avoid ignoring return values
1+
import RuleDetails from '@site/src/components/RuleDetails';
22

3-
## Rule id {#rule-id}
4-
5-
avoid-ignoring-return-values
6-
7-
## Severity {#severity}
8-
9-
Warning
10-
11-
## Description {#description}
3+
<RuleDetails version="4.2.0" severity="warning" />
124

135
Warns when a return value of a method or function invocation or a class instance property access is not used.
146

157
Silently ignoring such values might lead to a potential error especially when the invocation target is an immutable instance which has all its methods returning a new instance (for example, String or DateTime classes).
168

179
### Example {#example}
1810

19-
Bad:
11+
**Bad:**
2012

2113
```dart
2214
int foo() {
@@ -39,7 +31,7 @@ void main() {
3931
}
4032
```
4133

42-
Good:
34+
**Good:**
4335

4436
```dart
4537
int foo() {

0 commit comments

Comments
 (0)