@angular-eslint/eslint-plugin 21.0.2-alpha.10 → 21.0.2-alpha.12
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 +1 -0
- package/dist/configs/all.json +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/rules/prefer-signal-model.d.ts +8 -0
- package/dist/rules/prefer-signal-model.d.ts.map +1 -0
- package/dist/rules/prefer-signal-model.js +71 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -72,6 +72,7 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
|
|
|
72
72
|
| [`prefer-on-push-component-change-detection`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-on-push-component-change-detection.md) | Ensures component's `changeDetection` is set to `ChangeDetectionStrategy.OnPush` | | | :bulb: |
|
|
73
73
|
| [`prefer-output-emitter-ref`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-output-emitter-ref.md) | Use `OutputEmitterRef` instead of `@Output()` | | | |
|
|
74
74
|
| [`prefer-output-readonly`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-output-readonly.md) | Prefer to declare `@Output`, `OutputEmitterRef` and `OutputRef` as `readonly` since they are not supposed to be reassigned | | | :bulb: |
|
|
75
|
+
| [`prefer-signal-model`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-signal-model.md) | Use `model` instead of `input` and `output` for two-way bindings | | :wrench: | |
|
|
75
76
|
| [`prefer-signals`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-signals.md) | Use readonly signals instead of `@Input()`, `@ViewChild()` and other legacy decorators | | :wrench: | |
|
|
76
77
|
| [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | Ensures Components, Directives and Pipes do not opt out of standalone. | :white_check_mark: | | :bulb: |
|
|
77
78
|
| [`relative-url-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/relative-url-prefix.md) | The ./ and ../ prefix is standard syntax for relative URLs; don't depend on Angular's current ability to do without that prefix. | | | |
|
package/dist/configs/all.json
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@angular-eslint/prefer-on-push-component-change-detection": "error",
|
|
35
35
|
"@angular-eslint/prefer-output-emitter-ref": "error",
|
|
36
36
|
"@angular-eslint/prefer-output-readonly": "error",
|
|
37
|
+
"@angular-eslint/prefer-signal-model": "error",
|
|
37
38
|
"@angular-eslint/prefer-signals": "error",
|
|
38
39
|
"@angular-eslint/prefer-standalone": "error",
|
|
39
40
|
"@angular-eslint/relative-url-prefix": "error",
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ declare const _default: {
|
|
|
36
36
|
"@angular-eslint/prefer-on-push-component-change-detection": string;
|
|
37
37
|
"@angular-eslint/prefer-output-emitter-ref": string;
|
|
38
38
|
"@angular-eslint/prefer-output-readonly": string;
|
|
39
|
+
"@angular-eslint/prefer-signal-model": string;
|
|
39
40
|
"@angular-eslint/prefer-signals": string;
|
|
40
41
|
"@angular-eslint/prefer-standalone": string;
|
|
41
42
|
"@angular-eslint/relative-url-prefix": string;
|
|
@@ -110,6 +111,7 @@ declare const _default: {
|
|
|
110
111
|
"prefer-inject": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferInject", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
111
112
|
"prefer-output-emitter-ref": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferOutputEmitterRef", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
112
113
|
"prefer-output-readonly": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/prefer-output-readonly").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
114
|
+
"prefer-signal-model": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferSignalModel", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
113
115
|
"relative-url-prefix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"relativeUrlPrefix", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
114
116
|
"require-lifecycle-on-prototype": import("@typescript-eslint/utils/ts-eslint").RuleModule<"defineOnPrototype", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
115
117
|
"require-localize-metadata": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/require-localize-metadata").MessageIds, import("./rules/require-localize-metadata").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiJA,kBAuDE"}
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,7 @@ const prefer_host_metadata_property_1 = __importStar(require("./rules/prefer-hos
|
|
|
67
67
|
const prefer_on_push_component_change_detection_1 = __importStar(require("./rules/prefer-on-push-component-change-detection"));
|
|
68
68
|
const prefer_output_emitter_ref_1 = __importStar(require("./rules/prefer-output-emitter-ref"));
|
|
69
69
|
const prefer_output_readonly_1 = __importStar(require("./rules/prefer-output-readonly"));
|
|
70
|
+
const prefer_signal_model_1 = __importStar(require("./rules/prefer-signal-model"));
|
|
70
71
|
const prefer_inject_1 = __importStar(require("./rules/prefer-inject"));
|
|
71
72
|
const prefer_signals_1 = __importStar(require("./rules/prefer-signals"));
|
|
72
73
|
const prefer_standalone_1 = __importStar(require("./rules/prefer-standalone"));
|
|
@@ -122,6 +123,7 @@ module.exports = {
|
|
|
122
123
|
[prefer_inject_1.RULE_NAME]: prefer_inject_1.default,
|
|
123
124
|
[prefer_output_emitter_ref_1.RULE_NAME]: prefer_output_emitter_ref_1.default,
|
|
124
125
|
[prefer_output_readonly_1.RULE_NAME]: prefer_output_readonly_1.default,
|
|
126
|
+
[prefer_signal_model_1.RULE_NAME]: prefer_signal_model_1.default,
|
|
125
127
|
[relative_url_prefix_1.RULE_NAME]: relative_url_prefix_1.default,
|
|
126
128
|
[require_lifecycle_on_prototype_1.RULE_NAME]: require_lifecycle_on_prototype_1.default,
|
|
127
129
|
[require_localize_metadata_1.RULE_NAME]: require_localize_metadata_1.default,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type MessageIds = 'preferSignalModel';
|
|
2
|
+
export declare const RULE_NAME = "prefer-signal-model";
|
|
3
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferSignalModel", [], import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const RULE_DOCS_EXTENSION: {
|
|
6
|
+
rationale: string;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=prefer-signal-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-signal-model.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-signal-model.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAC7C,eAAO,MAAM,SAAS,wBAAwB,CAAC;;AAE/C,wBA0EG;AAEH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULE_DOCS_EXTENSION = exports.RULE_NAME = void 0;
|
|
4
|
+
const utils_1 = require("@angular-eslint/utils");
|
|
5
|
+
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
6
|
+
exports.RULE_NAME = 'prefer-signal-model';
|
|
7
|
+
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
8
|
+
name: exports.RULE_NAME,
|
|
9
|
+
meta: {
|
|
10
|
+
type: 'suggestion',
|
|
11
|
+
docs: {
|
|
12
|
+
description: 'Use `model` instead of `input` and `output` for two-way bindings',
|
|
13
|
+
},
|
|
14
|
+
fixable: 'code',
|
|
15
|
+
schema: [],
|
|
16
|
+
messages: {
|
|
17
|
+
preferSignalModel: 'Use `model` for two-way bindings instead of `input()` and `output()`',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultOptions: [],
|
|
21
|
+
create(context) {
|
|
22
|
+
const inputs = new Map();
|
|
23
|
+
const outputs = new Map();
|
|
24
|
+
return {
|
|
25
|
+
"PropertyDefinition > CallExpression[callee.name='input']"(node) {
|
|
26
|
+
const propertyDef = node.parent;
|
|
27
|
+
const propertyName = utils_1.ASTUtils.getPropertyDefinitionName(propertyDef);
|
|
28
|
+
inputs.set(propertyName, propertyDef);
|
|
29
|
+
},
|
|
30
|
+
"PropertyDefinition > CallExpression[callee.name='output']"(node) {
|
|
31
|
+
const propertyDef = node.parent;
|
|
32
|
+
const propertyName = utils_1.ASTUtils.getPropertyDefinitionName(propertyDef);
|
|
33
|
+
outputs.set(propertyName, propertyDef);
|
|
34
|
+
},
|
|
35
|
+
'ClassDeclaration:exit'() {
|
|
36
|
+
for (const [inputName, inputProperty] of inputs) {
|
|
37
|
+
const outputName = `${inputName}Change`;
|
|
38
|
+
const outputProperty = outputs.get(outputName);
|
|
39
|
+
if (outputProperty) {
|
|
40
|
+
// Report on the input property
|
|
41
|
+
context.report({
|
|
42
|
+
node: inputProperty,
|
|
43
|
+
messageId: 'preferSignalModel',
|
|
44
|
+
fix: (fixer) => {
|
|
45
|
+
const sourceCode = context.sourceCode;
|
|
46
|
+
const inputText = sourceCode.getText(inputProperty);
|
|
47
|
+
const fixedInputText = inputText.replace(/\binput\b/, 'model');
|
|
48
|
+
return [
|
|
49
|
+
utils_1.RuleFixes.getImportAddFix({
|
|
50
|
+
fixer,
|
|
51
|
+
importName: 'model',
|
|
52
|
+
moduleName: '@angular/core',
|
|
53
|
+
node: inputProperty,
|
|
54
|
+
}),
|
|
55
|
+
fixer.replaceText(inputProperty, fixedInputText),
|
|
56
|
+
fixer.remove(outputProperty),
|
|
57
|
+
].filter(utils_1.isNotNullOrUndefined);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Clear the maps for the next class
|
|
63
|
+
inputs.clear();
|
|
64
|
+
outputs.clear();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
exports.RULE_DOCS_EXTENSION = {
|
|
70
|
+
rationale: "The model() function is Angular's modern API for two-way bindings, combining both input and output into a single signal. When you have an input property paired with an output property that follows the naming pattern of `propertyChange` (e.g., `enabled` input with `enabledChange` output), this is the traditional pattern for two-way binding. The model() function provides a cleaner, more concise way to express this pattern with better type safety and integration with Angular's signal ecosystem. It eliminates the boilerplate of managing separate input and output properties while maintaining the same two-way binding functionality.",
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin",
|
|
3
|
-
"version": "21.0.2-alpha.
|
|
3
|
+
"version": "21.0.2-alpha.12",
|
|
4
4
|
"description": "ESLint plugin for Angular applications, following https://angular.dev/style-guide",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"ts-api-utils": "^2.1.0",
|
|
22
|
-
"@angular-eslint/
|
|
23
|
-
"@angular-eslint/
|
|
22
|
+
"@angular-eslint/utils": "21.0.2-alpha.12",
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "21.0.2-alpha.12"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@angular-eslint/test-utils": "21.0.2-alpha.
|
|
26
|
+
"@angular-eslint/test-utils": "21.0.2-alpha.12"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@typescript-eslint/utils": "^7.11.0 || ^8.0.0",
|