@angular-eslint/eslint-plugin 19.0.3-alpha.2 → 19.0.3-alpha.20

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
@@ -66,7 +66,7 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
66
66
  | [`pipe-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/pipe-prefix.md) | Enforce consistent prefix for pipes. | | | |
67
67
  | [`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: |
68
68
  | [`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: |
69
- | [`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 | | | :bulb: |
69
+ | [`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: | |
70
70
  | [`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: | :wrench: | |
71
71
  | [`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. See more at https://angular.dev/style-guide#style-05-04 | | | |
72
72
  | [`require-localize-metadata`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/require-localize-metadata.md) | Ensures that $localize tagged messages contain helpful metadata to aid with translations. | | | |
@@ -1,44 +1,44 @@
1
1
  {
2
- "parser": "@typescript-eslint/parser",
3
- "plugins": ["@angular-eslint"],
4
- "rules": {
5
- "@angular-eslint/component-class-suffix": "error",
6
- "@angular-eslint/component-max-inline-declarations": "error",
7
- "@angular-eslint/component-selector": "error",
8
- "@angular-eslint/consistent-component-styles": "error",
9
- "@angular-eslint/contextual-decorator": "error",
10
- "@angular-eslint/contextual-lifecycle": "error",
11
- "@angular-eslint/directive-class-suffix": "error",
12
- "@angular-eslint/directive-selector": "error",
13
- "@angular-eslint/no-async-lifecycle-method": "error",
14
- "@angular-eslint/no-attribute-decorator": "error",
15
- "@angular-eslint/no-conflicting-lifecycle": "error",
16
- "@angular-eslint/no-duplicates-in-metadata-arrays": "error",
17
- "@angular-eslint/no-empty-lifecycle-method": "error",
18
- "@angular-eslint/no-forward-ref": "error",
19
- "@angular-eslint/no-input-prefix": "error",
20
- "@angular-eslint/no-input-rename": "error",
21
- "@angular-eslint/no-inputs-metadata-property": "error",
22
- "@angular-eslint/no-lifecycle-call": "error",
23
- "@angular-eslint/no-output-native": "error",
24
- "@angular-eslint/no-output-on-prefix": "error",
25
- "@angular-eslint/no-output-rename": "error",
26
- "@angular-eslint/no-outputs-metadata-property": "error",
27
- "@angular-eslint/no-pipe-impure": "error",
28
- "@angular-eslint/no-queries-metadata-property": "error",
29
- "@angular-eslint/pipe-prefix": "error",
30
- "@angular-eslint/prefer-on-push-component-change-detection": "error",
31
- "@angular-eslint/prefer-output-readonly": "error",
32
- "@angular-eslint/prefer-signals": "error",
33
- "@angular-eslint/prefer-standalone": "error",
34
- "@angular-eslint/relative-url-prefix": "error",
35
- "@angular-eslint/require-localize-metadata": "error",
36
- "@angular-eslint/runtime-localize": "error",
37
- "@angular-eslint/sort-lifecycle-methods": "error",
38
- "@angular-eslint/use-component-selector": "error",
39
- "@angular-eslint/use-component-view-encapsulation": "error",
40
- "@angular-eslint/use-injectable-provided-in": "error",
41
- "@angular-eslint/use-lifecycle-interface": "error",
42
- "@angular-eslint/use-pipe-transform-interface": "error"
43
- }
2
+ "parser": "@typescript-eslint/parser",
3
+ "plugins": ["@angular-eslint"],
4
+ "rules": {
5
+ "@angular-eslint/component-class-suffix": "error",
6
+ "@angular-eslint/component-max-inline-declarations": "error",
7
+ "@angular-eslint/component-selector": "error",
8
+ "@angular-eslint/consistent-component-styles": "error",
9
+ "@angular-eslint/contextual-decorator": "error",
10
+ "@angular-eslint/contextual-lifecycle": "error",
11
+ "@angular-eslint/directive-class-suffix": "error",
12
+ "@angular-eslint/directive-selector": "error",
13
+ "@angular-eslint/no-async-lifecycle-method": "error",
14
+ "@angular-eslint/no-attribute-decorator": "error",
15
+ "@angular-eslint/no-conflicting-lifecycle": "error",
16
+ "@angular-eslint/no-duplicates-in-metadata-arrays": "error",
17
+ "@angular-eslint/no-empty-lifecycle-method": "error",
18
+ "@angular-eslint/no-forward-ref": "error",
19
+ "@angular-eslint/no-input-prefix": "error",
20
+ "@angular-eslint/no-input-rename": "error",
21
+ "@angular-eslint/no-inputs-metadata-property": "error",
22
+ "@angular-eslint/no-lifecycle-call": "error",
23
+ "@angular-eslint/no-output-native": "error",
24
+ "@angular-eslint/no-output-on-prefix": "error",
25
+ "@angular-eslint/no-output-rename": "error",
26
+ "@angular-eslint/no-outputs-metadata-property": "error",
27
+ "@angular-eslint/no-pipe-impure": "error",
28
+ "@angular-eslint/no-queries-metadata-property": "error",
29
+ "@angular-eslint/pipe-prefix": "error",
30
+ "@angular-eslint/prefer-on-push-component-change-detection": "error",
31
+ "@angular-eslint/prefer-output-readonly": "error",
32
+ "@angular-eslint/prefer-signals": "error",
33
+ "@angular-eslint/prefer-standalone": "error",
34
+ "@angular-eslint/relative-url-prefix": "error",
35
+ "@angular-eslint/require-localize-metadata": "error",
36
+ "@angular-eslint/runtime-localize": "error",
37
+ "@angular-eslint/sort-lifecycle-methods": "error",
38
+ "@angular-eslint/use-component-selector": "error",
39
+ "@angular-eslint/use-component-view-encapsulation": "error",
40
+ "@angular-eslint/use-injectable-provided-in": "error",
41
+ "@angular-eslint/use-lifecycle-interface": "error",
42
+ "@angular-eslint/use-pipe-transform-interface": "error"
43
+ }
44
44
  }
@@ -1,19 +1,19 @@
1
1
  {
2
- "parser": "@typescript-eslint/parser",
3
- "plugins": ["@angular-eslint"],
4
- "rules": {
5
- "@angular-eslint/component-class-suffix": "error",
6
- "@angular-eslint/contextual-lifecycle": "error",
7
- "@angular-eslint/directive-class-suffix": "error",
8
- "@angular-eslint/no-empty-lifecycle-method": "error",
9
- "@angular-eslint/no-input-rename": "error",
10
- "@angular-eslint/no-inputs-metadata-property": "error",
11
- "@angular-eslint/no-output-native": "error",
12
- "@angular-eslint/no-output-on-prefix": "error",
13
- "@angular-eslint/no-output-rename": "error",
14
- "@angular-eslint/no-outputs-metadata-property": "error",
15
- "@angular-eslint/prefer-standalone": "error",
16
- "@angular-eslint/use-pipe-transform-interface": "error",
17
- "@angular-eslint/use-lifecycle-interface": "warn"
18
- }
2
+ "parser": "@typescript-eslint/parser",
3
+ "plugins": ["@angular-eslint"],
4
+ "rules": {
5
+ "@angular-eslint/component-class-suffix": "error",
6
+ "@angular-eslint/contextual-lifecycle": "error",
7
+ "@angular-eslint/directive-class-suffix": "error",
8
+ "@angular-eslint/no-empty-lifecycle-method": "error",
9
+ "@angular-eslint/no-input-rename": "error",
10
+ "@angular-eslint/no-inputs-metadata-property": "error",
11
+ "@angular-eslint/no-output-native": "error",
12
+ "@angular-eslint/no-output-on-prefix": "error",
13
+ "@angular-eslint/no-output-rename": "error",
14
+ "@angular-eslint/no-outputs-metadata-property": "error",
15
+ "@angular-eslint/prefer-standalone": "error",
16
+ "@angular-eslint/use-pipe-transform-interface": "error",
17
+ "@angular-eslint/use-lifecycle-interface": "warn"
18
+ }
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"no-input-prefix.d.ts","sourceRoot":"","sources":["../../src/rules/no-input-prefix.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,eAAe,CAAC;AACzC,eAAO,MAAM,SAAS,oBAAoB,CAAC;;AAE3C,wBA0HG"}
1
+ {"version":3,"file":"no-input-prefix.d.ts","sourceRoot":"","sources":["../../src/rules/no-input-prefix.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,eAAe,CAAC;AACzC,eAAO,MAAM,SAAS,oBAAoB,CAAC;;AAE3C,wBAwIG"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RULE_NAME = void 0;
4
4
  const utils_1 = require("@angular-eslint/utils");
5
+ const utils_2 = require("@typescript-eslint/utils");
5
6
  const create_eslint_rule_1 = require("../utils/create-eslint-rule");
6
7
  exports.RULE_NAME = 'no-input-prefix';
7
8
  exports.default = (0, create_eslint_rule_1.createESLintRule)({
@@ -34,6 +35,16 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
34
35
  return {
35
36
  [utils_1.Selectors.INPUT_PROPERTY_OR_SETTER](node) {
36
37
  const rawPropertyName = utils_1.ASTUtils.getRawText(node);
38
+ // The child that matched was just a literal initializer of a property definition
39
+ if (node.parent?.type === utils_2.TSESTree.AST_NODE_TYPES.PropertyDefinition) {
40
+ const initializingValue = node.parent.value;
41
+ if (initializingValue?.type === utils_2.TSESTree.AST_NODE_TYPES.Literal &&
42
+ rawPropertyName === utils_1.ASTUtils.getRawText(initializingValue) &&
43
+ node.range[0] === initializingValue.range[0] &&
44
+ node.range[1] === initializingValue.range[1]) {
45
+ return;
46
+ }
47
+ }
37
48
  const hasDisallowedPrefix = prefixes.some((prefix) => isDisallowedPrefix(prefix, rawPropertyName));
38
49
  // Direct violation on the property name
39
50
  if (hasDisallowedPrefix) {
@@ -8,7 +8,7 @@ type Options = [
8
8
  additionalSignalCreationFunctions: string[];
9
9
  }
10
10
  ];
11
- export type MessageIds = 'preferInputSignals' | 'preferQuerySignals' | 'preferReadonlySignalProperties' | 'suggestAddReadonlyModifier';
11
+ export type MessageIds = 'preferInputSignals' | 'preferQuerySignals' | 'preferReadonlySignalProperties';
12
12
  export declare const RULE_NAME = "prefer-signals";
13
13
  declare const _default: ESLintUtils.RuleModule<MessageIds, Options, import("../utils/create-eslint-rule").RuleDocs, ESLintUtils.RuleListener>;
14
14
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-signals.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-signals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvE,KAAK,OAAO,GAAG;IACb;QACE,8BAA8B,EAAE,OAAO,CAAC;QACxC,kBAAkB,EAAE,OAAO,CAAC;QAC5B,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,EAAE,OAAO,CAAC;QACzB,iCAAiC,EAAE,MAAM,EAAE,CAAC;KAC7C;CACF,CAAC;AA4BF,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACpB,oBAAoB,GACpB,gCAAgC,GAChC,4BAA4B,CAAC;AACjC,eAAO,MAAM,SAAS,mBAAmB,CAAC;;AAE1C,wBA4KG"}
1
+ {"version":3,"file":"prefer-signals.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-signals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvE,KAAK,OAAO,GAAG;IACb;QACE,8BAA8B,EAAE,OAAO,CAAC;QACxC,kBAAkB,EAAE,OAAO,CAAC;QAC5B,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,EAAE,OAAO,CAAC;QACzB,iCAAiC,EAAE,MAAM,EAAE,CAAC;KAC7C;CACF,CAAC;AA6BF,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACpB,oBAAoB,GACpB,gCAAgC,CAAC;AACrC,eAAO,MAAM,SAAS,mBAAmB,CAAC;;AAE1C,wBAsLG"}
@@ -22,6 +22,7 @@ const KNOWN_SIGNAL_CREATION_FUNCTIONS = new Set([
22
22
  'contentChild',
23
23
  'contentChildren',
24
24
  'input',
25
+ 'linkedSignal',
25
26
  'model',
26
27
  'signal',
27
28
  'toSignal',
@@ -36,7 +37,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
36
37
  docs: {
37
38
  description: 'Use readonly signals instead of `@Input()`, `@ViewChild()` and other legacy decorators',
38
39
  },
39
- hasSuggestions: true,
40
+ fixable: 'code',
40
41
  schema: [
41
42
  {
42
43
  type: 'object',
@@ -70,7 +71,6 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
70
71
  preferInputSignals: 'Use `InputSignal`s (e.g. via `input()`) for Component input properties rather than the legacy `@Input()` decorator',
71
72
  preferQuerySignals: 'Use the `{{function}}` function instead of the `{{decorator}}` decorator',
72
73
  preferReadonlySignalProperties: 'Properties declared using signals should be marked as `readonly` since they should not be reassigned',
73
- suggestAddReadonlyModifier: 'Add `readonly` modifier',
74
74
  },
75
75
  },
76
76
  defaultOptions: [{ ...DEFAULT_OPTIONS }],
@@ -97,8 +97,22 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
97
97
  // There is no type annotation, so try to
98
98
  // use the value assigned to the property
99
99
  // to determine whether it would be a signal.
100
- if (node.value?.type === utils_2.AST_NODE_TYPES.CallExpression) {
101
- let callee = node.value.callee;
100
+ let value = node.value;
101
+ if (value?.type === utils_2.AST_NODE_TYPES.CallExpression) {
102
+ const callee = value.callee;
103
+ // A `WritableSignal` can be turned into a `Signal` using
104
+ // the `.asReadonly()` method. If that method is being,
105
+ // called, then we need to look at the object that the method
106
+ // is called on to determine if it's being called on a `Signal`.
107
+ if (callee.type === utils_2.AST_NODE_TYPES.MemberExpression) {
108
+ if (callee.property.type === utils_2.AST_NODE_TYPES.Identifier &&
109
+ callee.property.name === 'asReadonly') {
110
+ value = callee.object;
111
+ }
112
+ }
113
+ }
114
+ if (value?.type === utils_2.AST_NODE_TYPES.CallExpression) {
115
+ let callee = value.callee;
102
116
  // Some signal-creating functions have a `.required`
103
117
  // member. For example, `input.required()`.
104
118
  if (callee.type === utils_2.AST_NODE_TYPES.MemberExpression) {
@@ -127,12 +141,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
127
141
  context.report({
128
142
  node: node.key,
129
143
  messageId: 'preferReadonlySignalProperties',
130
- suggest: [
131
- {
132
- messageId: 'suggestAddReadonlyModifier',
133
- fix: (fixer) => fixer.insertTextBefore(node.key, 'readonly '),
134
- },
135
- ],
144
+ fix: (fixer) => fixer.insertTextBefore(node.key, 'readonly '),
136
145
  });
137
146
  }
138
147
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin",
3
- "version": "19.0.3-alpha.2",
3
+ "version": "19.0.3-alpha.20",
4
4
  "description": "ESLint plugin for Angular applications, following https://angular.dev/style-guide",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -18,11 +18,11 @@
18
18
  "LICENSE"
19
19
  ],
20
20
  "dependencies": {
21
- "@angular-eslint/bundled-angular-compiler": "19.0.3-alpha.2",
22
- "@angular-eslint/utils": "19.0.3-alpha.2"
21
+ "@angular-eslint/bundled-angular-compiler": "19.0.3-alpha.20",
22
+ "@angular-eslint/utils": "19.0.3-alpha.20"
23
23
  },
24
24
  "devDependencies": {
25
- "@angular-eslint/test-utils": "19.0.3-alpha.2"
25
+ "@angular-eslint/test-utils": "19.0.3-alpha.20"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@typescript-eslint/utils": "^7.11.0 || ^8.0.0",