@yoo-digital/eslint-plugin-angular 1.4.0 → 2.0.1
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 +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/rules/{prefer-boolean-attribute-shorthand.d.ts → boolean-attribute-html.d.ts} +1 -1
- package/dist/rules/{prefer-boolean-attribute-shorthand.js → boolean-attribute-html.js} +1 -1
- package/dist/rules/{require-boolean-attribute-transform.d.ts → boolean-attribute-ts.d.ts} +1 -1
- package/dist/rules/{require-boolean-attribute-transform.js → boolean-attribute-ts.js} +14 -10
- package/dist/rules/index.d.ts +2 -2
- package/dist/rules/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,15 +12,15 @@ Wrong code is yellow/red underlined in VScode, it can also be raised running : `
|
|
|
12
12
|
|
|
13
13
|
This feature consists of **two complementary rules**:
|
|
14
14
|
|
|
15
|
-
1. **`
|
|
16
|
-
2. **`
|
|
15
|
+
1. **`boolean-attribute-ts`** - TypeScript rule that enforces `booleanAttribute` transform on boolean inputs
|
|
16
|
+
2. **`boolean-attribute-html`** - Template rule that enforces shorthand syntax for `[attr]="true"` bindings
|
|
17
17
|
|
|
18
18
|
### Setting
|
|
19
19
|
```json
|
|
20
20
|
{
|
|
21
21
|
"rules": {
|
|
22
|
-
"@yoo-digital/eslint-plugin-angular/
|
|
23
|
-
"@yoo-digital/eslint-plugin-angular/
|
|
22
|
+
"@yoo-digital/eslint-plugin-angular/boolean-attribute-ts": "error",
|
|
23
|
+
"@yoo-digital/eslint-plugin-angular/boolean-attribute-html": "error"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ export declare const configs: {
|
|
|
3
3
|
default: {
|
|
4
4
|
plugins: string[];
|
|
5
5
|
rules: {
|
|
6
|
-
'@yoo-digital/angular/
|
|
7
|
-
'@yoo-digital/angular/
|
|
6
|
+
'@yoo-digital/angular/boolean-attribute-html': string;
|
|
7
|
+
'@yoo-digital/angular/boolean-attribute-ts': string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
recommended: {
|
|
11
11
|
plugins: string[];
|
|
12
12
|
rules: {
|
|
13
|
-
'@yoo-digital/angular/
|
|
14
|
-
'@yoo-digital/angular/
|
|
13
|
+
'@yoo-digital/angular/boolean-attribute-html': string;
|
|
14
|
+
'@yoo-digital/angular/boolean-attribute-ts': string;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
};
|
package/dist/index.js
CHANGED
|
@@ -3,22 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.configs = exports.rules = void 0;
|
|
4
4
|
const rules_1 = require("./rules");
|
|
5
5
|
exports.rules = {
|
|
6
|
-
'
|
|
7
|
-
'
|
|
6
|
+
'boolean-attribute-html': rules_1.preferBooleanAttributeShorthandRule,
|
|
7
|
+
'boolean-attribute-ts': rules_1.requireBooleanAttributeTransformRule,
|
|
8
8
|
};
|
|
9
9
|
exports.configs = {
|
|
10
10
|
default: {
|
|
11
11
|
plugins: ['@yoo-digital/eslint-plugin-angular'],
|
|
12
12
|
rules: {
|
|
13
|
-
'@yoo-digital/angular/
|
|
14
|
-
'@yoo-digital/angular/
|
|
13
|
+
'@yoo-digital/angular/boolean-attribute-html': 'warn',
|
|
14
|
+
'@yoo-digital/angular/boolean-attribute-ts': 'warn',
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
recommended: {
|
|
18
18
|
plugins: ['@yoo-digital/eslint-plugin-angular'],
|
|
19
19
|
rules: {
|
|
20
|
-
'@yoo-digital/angular/
|
|
21
|
-
'@yoo-digital/angular/
|
|
20
|
+
'@yoo-digital/angular/boolean-attribute-html': 'error',
|
|
21
|
+
'@yoo-digital/angular/boolean-attribute-ts': 'error',
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
2
|
type MessageIds = 'preferTrue' | 'suggestTrue';
|
|
3
|
-
export declare const RULE_NAME = "
|
|
3
|
+
export declare const RULE_NAME = "boolean-attribute-html";
|
|
4
4
|
/**
|
|
5
5
|
* This rule enforces shorthand syntax for boolean inputs bound to true.
|
|
6
6
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.preferBooleanAttributeShorthandRule = exports.RULE_NAME = void 0;
|
|
4
4
|
const utils_1 = require("@angular-eslint/utils");
|
|
5
|
-
exports.RULE_NAME = '
|
|
5
|
+
exports.RULE_NAME = 'boolean-attribute-html';
|
|
6
6
|
/**
|
|
7
7
|
* This rule enforces shorthand syntax for boolean inputs bound to true.
|
|
8
8
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
2
|
type MessageIds = 'requireTransformDecorator' | 'requireTransformSignal';
|
|
3
|
-
export declare const RULE_NAME = "
|
|
3
|
+
export declare const RULE_NAME = "boolean-attribute-ts";
|
|
4
4
|
/**
|
|
5
5
|
* This rule enforces that boolean @Input() properties and input() signals
|
|
6
6
|
* use the booleanAttribute transform.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireBooleanAttributeTransformRule = exports.RULE_NAME = void 0;
|
|
4
|
-
exports.RULE_NAME = '
|
|
4
|
+
exports.RULE_NAME = 'boolean-attribute-ts';
|
|
5
5
|
/**
|
|
6
6
|
* This rule enforces that boolean @Input() properties and input() signals
|
|
7
7
|
* use the booleanAttribute transform.
|
|
@@ -105,19 +105,22 @@ exports.requireBooleanAttributeTransformRule = {
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
const callExpr = node.init;
|
|
108
|
-
// Check if it's a boolean input
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
// Check if it's a boolean input (with or without type arguments)
|
|
109
|
+
let isBooleanInput = false;
|
|
110
|
+
if (callExpr.typeArguments && callExpr.typeArguments.params.length > 0) {
|
|
111
|
+
const firstTypeParam = callExpr.typeArguments.params[0];
|
|
112
|
+
isBooleanInput = firstTypeParam.type === 'TSBooleanKeyword';
|
|
111
113
|
}
|
|
112
|
-
|
|
113
|
-
if (firstTypeParam.type !== 'TSBooleanKeyword') {
|
|
114
|
+
if (!isBooleanInput) {
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
117
|
+
// At this point, we know typeArguments exists and has at least one boolean param
|
|
118
|
+
const typeArgs = callExpr.typeArguments;
|
|
116
119
|
// Check if it already has BooleanInput as second type parameter
|
|
117
|
-
const hasBooleanInput =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
const hasBooleanInput = typeArgs.params.length > 1 &&
|
|
121
|
+
typeArgs.params[1].type === 'TSTypeReference' &&
|
|
122
|
+
typeArgs.params[1].typeName.type === 'Identifier' &&
|
|
123
|
+
typeArgs.params[1].typeName.name === 'BooleanInput';
|
|
121
124
|
// Check if it already has transform in options
|
|
122
125
|
const hasTransformOption = callExpr.arguments.length > 1 &&
|
|
123
126
|
callExpr.arguments[1].type === 'ObjectExpression' &&
|
|
@@ -126,6 +129,7 @@ exports.requireBooleanAttributeTransformRule = {
|
|
|
126
129
|
prop.key.name === 'transform' &&
|
|
127
130
|
prop.value.type === 'Identifier' &&
|
|
128
131
|
prop.value.name === 'booleanAttribute');
|
|
132
|
+
// Both BooleanInput type and transform option are required
|
|
129
133
|
if (hasBooleanInput && hasTransformOption) {
|
|
130
134
|
return; // Already correctly configured
|
|
131
135
|
}
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { RULE_NAME as BOOLEAN_ATTRIBUTE_HTML_RULE_NAME, preferBooleanAttributeShorthandRule } from './boolean-attribute-html';
|
|
2
|
+
export { RULE_NAME as BOOLEAN_ATTRIBUTE_TS_RULE_NAME, requireBooleanAttributeTransformRule } from './boolean-attribute-ts';
|
package/dist/rules/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
Object.defineProperty(exports, "
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "
|
|
9
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.requireBooleanAttributeTransformRule = exports.BOOLEAN_ATTRIBUTE_TS_RULE_NAME = exports.preferBooleanAttributeShorthandRule = exports.BOOLEAN_ATTRIBUTE_HTML_RULE_NAME = void 0;
|
|
4
|
+
var boolean_attribute_html_1 = require("./boolean-attribute-html");
|
|
5
|
+
Object.defineProperty(exports, "BOOLEAN_ATTRIBUTE_HTML_RULE_NAME", { enumerable: true, get: function () { return boolean_attribute_html_1.RULE_NAME; } });
|
|
6
|
+
Object.defineProperty(exports, "preferBooleanAttributeShorthandRule", { enumerable: true, get: function () { return boolean_attribute_html_1.preferBooleanAttributeShorthandRule; } });
|
|
7
|
+
var boolean_attribute_ts_1 = require("./boolean-attribute-ts");
|
|
8
|
+
Object.defineProperty(exports, "BOOLEAN_ATTRIBUTE_TS_RULE_NAME", { enumerable: true, get: function () { return boolean_attribute_ts_1.RULE_NAME; } });
|
|
9
|
+
Object.defineProperty(exports, "requireBooleanAttributeTransformRule", { enumerable: true, get: function () { return boolean_attribute_ts_1.requireBooleanAttributeTransformRule; } });
|
package/package.json
CHANGED