@yoo-digital/eslint-plugin-angular 2.0.7 → 2.0.9
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 +35 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,48 +1,28 @@
|
|
|
1
1
|
# YOO ESLint plugin Angular
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Aim
|
|
4
4
|
|
|
5
|
-
Here should live all custom Angular lint rules that eslint does not already provide.
|
|
5
|
+
Here should live all ***custom Angular lint rules*** that eslint does not already provide.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Use
|
|
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
|
{
|
|
18
|
+
"files": ['**/*.ts'],
|
|
21
19
|
"rules": {
|
|
22
|
-
"@yoo-digital/eslint-plugin-angular/boolean-input": "error",
|
|
23
20
|
"@yoo-digital/eslint-plugin-angular/boolean-attribute-shorthand": "error"
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
```
|
|
27
24
|
|
|
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
|
|
25
|
+
#### Import
|
|
46
26
|
`booleanAttribute @angular/core`
|
|
47
27
|
|
|
48
28
|
`BooleanInput @angular/cdk/coercion`
|
|
@@ -61,6 +41,33 @@ isVegan = input<boolean, BooleanInput>(true|false, { transform: booleanAttribute
|
|
|
61
41
|
@Input({ transform: booleanAttribute }) isVegan: boolean = true|false;
|
|
62
42
|
```
|
|
63
43
|
|
|
44
|
+
## 2️⃣ boolean-attribute-shorthand
|
|
45
|
+
|
|
46
|
+
HTML rule that enforces shorthand syntax for `[attr]="true"` bindings
|
|
47
|
+
|
|
48
|
+
### Setting
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"files": ['**/*.html'],
|
|
52
|
+
"rules": {
|
|
53
|
+
"@yoo-digital/eslint-plugin-angular/boolean-attribute-shorthand": "error"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### True value
|
|
59
|
+
```html
|
|
60
|
+
<mealComponent [isVegan]="true" />
|
|
61
|
+
<!-- Lint issue enforcing to be : -->
|
|
62
|
+
<mealComponent isVegan />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### False value (bypassed)
|
|
66
|
+
```html
|
|
67
|
+
<mealComponent [isVegan]="false" />
|
|
68
|
+
<!-- No lint issue, to be able to address false value for a default true input -->
|
|
69
|
+
```
|
|
70
|
+
|
|
64
71
|
### Default value
|
|
65
72
|
#### Default true
|
|
66
73
|
|
|
@@ -98,6 +105,4 @@ HTML set it true or false this way :
|
|
|
98
105
|
<mealComponent isVegan />
|
|
99
106
|
<!-- False value -->
|
|
100
107
|
<mealComponent />
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## 2️⃣ ...
|
|
108
|
+
```
|
package/package.json
CHANGED