@yoo-digital/eslint-plugin-angular 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,41 +8,20 @@ Here should live all custom Angular lint rules that eslint does not already prov
|
|
|
8
8
|
|
|
9
9
|
Wrong code is yellow/red underlined in VScode, it can also be raised running : `npm run lint`, autofixing them with : `npm run lint:fix`
|
|
10
10
|
|
|
11
|
-
## 1️⃣
|
|
11
|
+
## 1️⃣ boolean-input
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
1. **`boolean-input`** - TypeScript rule that enforces `booleanAttribute` transform on boolean inputs
|
|
16
|
-
2. **`boolean-attribute-shorthand`** - Template rule that enforces shorthand syntax for `[attr]="true"` bindings
|
|
13
|
+
TypeScript rule that enforces `booleanAttribute` transform on boolean inputs
|
|
17
14
|
|
|
18
15
|
### Setting
|
|
19
16
|
```json
|
|
20
17
|
{
|
|
21
18
|
"rules": {
|
|
22
|
-
"@yoo-digital/eslint-plugin-angular/boolean-input": "error",
|
|
23
19
|
"@yoo-digital/eslint-plugin-angular/boolean-attribute-shorthand": "error"
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
22
|
```
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#### True value
|
|
31
|
-
```html
|
|
32
|
-
<mealComponent [isVegan]="true" />
|
|
33
|
-
<!-- Lint issue enforcing to be : -->
|
|
34
|
-
<mealComponent isVegan />
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
#### False value (bypassed)
|
|
38
|
-
```html
|
|
39
|
-
<mealComponent [isVegan]="false" />
|
|
40
|
-
<!-- No lint issue, to be able to address false value for a default true input -->
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Typescript
|
|
44
|
-
|
|
45
|
-
#### Imports
|
|
24
|
+
#### Import
|
|
46
25
|
`booleanAttribute @angular/core`
|
|
47
26
|
|
|
48
27
|
`BooleanInput @angular/cdk/coercion`
|
|
@@ -61,6 +40,32 @@ isVegan = input<boolean, BooleanInput>(true|false, { transform: booleanAttribute
|
|
|
61
40
|
@Input({ transform: booleanAttribute }) isVegan: boolean = true|false;
|
|
62
41
|
```
|
|
63
42
|
|
|
43
|
+
## 2️⃣ boolean-attribute-shorthand
|
|
44
|
+
|
|
45
|
+
HTML rule that enforces shorthand syntax for `[attr]="true"` bindings
|
|
46
|
+
|
|
47
|
+
### Setting
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"rules": {
|
|
51
|
+
"@yoo-digital/eslint-plugin-angular/boolean-attribute-shorthand": "error"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### True value
|
|
57
|
+
```html
|
|
58
|
+
<mealComponent [isVegan]="true" />
|
|
59
|
+
<!-- Lint issue enforcing to be : -->
|
|
60
|
+
<mealComponent isVegan />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### False value (bypassed)
|
|
64
|
+
```html
|
|
65
|
+
<mealComponent [isVegan]="false" />
|
|
66
|
+
<!-- No lint issue, to be able to address false value for a default true input -->
|
|
67
|
+
```
|
|
68
|
+
|
|
64
69
|
### Default value
|
|
65
70
|
#### Default true
|
|
66
71
|
|
|
@@ -98,6 +103,4 @@ HTML set it true or false this way :
|
|
|
98
103
|
<mealComponent isVegan />
|
|
99
104
|
<!-- False value -->
|
|
100
105
|
<mealComponent />
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## 2️⃣ ...
|
|
106
|
+
```
|
package/package.json
CHANGED