@yoo-digital/eslint-plugin-angular 3.0.4 → 3.0.7

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 CHANGED
@@ -6,7 +6,8 @@ Here should live all ***custom Angular lint rules*** that eslint does not alread
6
6
 
7
7
  ## Use
8
8
 
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`
9
+ Wrong code is yellow/red underlined in VScode, it can also be raised running : `npm run lint`
10
+ Autofixing lint issues with : `npm run lint:fix`
10
11
 
11
12
  ## 1️⃣ boolean-input
12
13
 
@@ -105,4 +106,30 @@ HTML set it true or false this way :
105
106
  <mealComponent isVegan />
106
107
  <!-- False value -->
107
108
  <mealComponent />
108
- ```
109
+ ```
110
+
111
+ ### Required boolean input
112
+
113
+ Should be avoided as it might be in conflict with boolean-attribute-shorthand
114
+ ```typescript
115
+ isVegan = input.required<boolean, BooleanInput>({
116
+ transform: booleanAttribute,
117
+ });
118
+ ```
119
+
120
+ ```html
121
+ <!-- This will not work : -->
122
+ <!-- True value -->
123
+ <mealComponent isVegan />
124
+ <!-- False value -->
125
+ <mealComponent />
126
+
127
+ <!-- Values must be set, which does not respect boolean-attribute-shorthand : -->
128
+ <!-- True value -->
129
+ <mealComponent [isVegan]="true" />
130
+ <!-- False value -->
131
+ <mealComponent [isVegan]="false" />
132
+ ```
133
+
134
+
135
+
@@ -65,13 +65,17 @@ exports.requireBooleanAttributeTransformRule = {
65
65
  messageId: 'requireTransformDecorator',
66
66
  data: { name: propertyName },
67
67
  fix(fixer) {
68
- const decoratorNode = inputDecorator?.expression;
69
- if (!decoratorNode || decoratorNode.type !== 'CallExpression') {
68
+ if (!inputDecorator) {
70
69
  return null;
71
70
  }
72
- const decoratorStart = decoratorNode.range[0];
73
- const decoratorEnd = decoratorNode.range[1];
74
- // Generate the fixed decorator
71
+ const decoratorNode = inputDecorator.expression;
72
+ if (decoratorNode.type !== 'CallExpression') {
73
+ return null;
74
+ }
75
+ // Use the decorator's range (includes @) not just the expression
76
+ const decoratorStart = inputDecorator.range[0];
77
+ const decoratorEnd = inputDecorator.range[1];
78
+ // Generate the fixed decorator (without @ since we're replacing the full decorator)
75
79
  let newDecorator;
76
80
  if (decoratorNode.arguments.length === 0) {
77
81
  // @Input() → @Input({ transform: booleanAttribute })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoo-digital/eslint-plugin-angular",
3
- "version": "3.0.4",
3
+ "version": "3.0.7",
4
4
  "description": "Yoo Digital custom Angular ESLint plugin for enforcing boolean attribute best practices.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",