@angular-eslint/eslint-plugin 19.5.1-alpha.10 → 19.5.1-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 CHANGED
@@ -65,7 +65,7 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
65
65
  | [`no-pipe-impure`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-pipe-impure.md) | Disallows the declaration of impure pipes | | | :bulb: |
66
66
  | [`no-queries-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-queries-metadata-property.md) | Disallows usage of the `queries` metadata property. See more at https://angular.dev/style-guide#style-05-12. | | | |
67
67
  | [`pipe-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/pipe-prefix.md) | Enforce consistent prefix for pipes. | | | |
68
- | [`prefer-inject`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-inject.md) | Prefer using the inject() function over constructor parameter injection | :white_check_mark: | | |
68
+ | [`prefer-inject`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-inject.md) | Prefer using the inject() function over constructor parameter injection | | | |
69
69
  | [`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: |
70
70
  | [`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()` | | | |
71
71
  | [`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: |
@@ -12,7 +12,6 @@
12
12
  "@angular-eslint/no-output-on-prefix": "error",
13
13
  "@angular-eslint/no-output-rename": "error",
14
14
  "@angular-eslint/no-outputs-metadata-property": "error",
15
- "@angular-eslint/prefer-inject": "error",
16
15
  "@angular-eslint/prefer-standalone": "error",
17
16
  "@angular-eslint/use-pipe-transform-interface": "error",
18
17
  "@angular-eslint/use-lifecycle-interface": "warn"
package/dist/index.d.ts CHANGED
@@ -62,7 +62,6 @@ declare const _default: {
62
62
  "@angular-eslint/no-output-on-prefix": string;
63
63
  "@angular-eslint/no-output-rename": string;
64
64
  "@angular-eslint/no-outputs-metadata-property": string;
65
- "@angular-eslint/prefer-inject": string;
66
65
  "@angular-eslint/prefer-standalone": string;
67
66
  "@angular-eslint/use-pipe-transform-interface": string;
68
67
  "@angular-eslint/use-lifecycle-interface": string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA,kBAkDE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA,kBAkDE"}
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-inject.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-inject.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AACxC,eAAO,MAAM,SAAS,kBAAkB,CAAC;;AAEzC,wBA8GG"}
1
+ {"version":3,"file":"prefer-inject.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-inject.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AACxC,eAAO,MAAM,SAAS,kBAAkB,CAAC;;AAEzC,wBAiGG"}
@@ -11,7 +11,6 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
11
11
  type: 'suggestion',
12
12
  docs: {
13
13
  description: 'Prefer using the inject() function over constructor parameter injection',
14
- recommended: 'recommended',
15
14
  },
16
15
  schema: [],
17
16
  messages: {
@@ -68,19 +67,10 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
68
67
  }
69
68
  return {
70
69
  [`${utils_1.Selectors.decoratorDefinition(angularDecoratorsPattern)} > ClassBody > MethodDefinition[kind="constructor"]`](node) {
71
- const params = node.value.params;
70
+ const params = node.value.params ?? [];
72
71
  if (params.length === 0) {
73
72
  return;
74
73
  }
75
- // ignore constructors that only call super() (no parameters to inject)
76
- const body = node.value.body?.body ?? [];
77
- const onlySuper = body.length === 1 &&
78
- body[0].type === utils_2.AST_NODE_TYPES.ExpressionStatement &&
79
- body[0].expression.type === utils_2.AST_NODE_TYPES.CallExpression &&
80
- body[0].expression.callee.type === utils_2.AST_NODE_TYPES.Super;
81
- if (onlySuper && params.length === 0) {
82
- return;
83
- }
84
74
  for (const param of params) {
85
75
  if (shouldReportParameter(param)) {
86
76
  context.report({ node: param, messageId: 'preferInject' });
@@ -1 +1 @@
1
- {"version":3,"file":"use-lifecycle-interface.d.ts","sourceRoot":"","sources":["../../src/rules/use-lifecycle-interface.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,uBAAuB,CAAC;AACjD,eAAO,MAAM,SAAS,4BAA4B,CAAC;;AAGnD,wBAgEG"}
1
+ {"version":3,"file":"use-lifecycle-interface.d.ts","sourceRoot":"","sources":["../../src/rules/use-lifecycle-interface.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,uBAAuB,CAAC;AACjD,eAAO,MAAM,SAAS,4BAA4B,CAAC;;AAGnD,wBAyEG"}
@@ -24,9 +24,14 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
24
24
  ...utils_1.ASTUtils.ANGULAR_LIFECYCLE_METHODS,
25
25
  ]);
26
26
  return {
27
- [`MethodDefinition[key.name=${angularLifecycleMethodsPattern}]`]({ key, parent: { parent }, }) {
27
+ [`MethodDefinition[key.name=${angularLifecycleMethodsPattern}]`](node) {
28
+ const { key, parent: { parent }, } = node;
28
29
  if (!utils_1.ASTUtils.getAngularClassDecorator(parent))
29
30
  return;
31
+ // Do not report the method if it has the override keyword because it implies the base class is responsible for the implementation
32
+ if (node.override) {
33
+ return;
34
+ }
30
35
  const declaredLifecycleInterfaces = utils_1.ASTUtils.getDeclaredAngularLifecycleInterfaces(parent);
31
36
  const methodName = key
32
37
  .name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin",
3
- "version": "19.5.1-alpha.10",
3
+ "version": "19.5.1-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",
@@ -18,11 +18,11 @@
18
18
  "LICENSE"
19
19
  ],
20
20
  "dependencies": {
21
- "@angular-eslint/bundled-angular-compiler": "19.5.1-alpha.10",
22
- "@angular-eslint/utils": "19.5.1-alpha.10"
21
+ "@angular-eslint/bundled-angular-compiler": "19.5.1-alpha.12",
22
+ "@angular-eslint/utils": "19.5.1-alpha.12"
23
23
  },
24
24
  "devDependencies": {
25
- "@angular-eslint/test-utils": "19.5.1-alpha.10"
25
+ "@angular-eslint/test-utils": "19.5.1-alpha.12"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@typescript-eslint/utils": "^7.11.0 || ^8.0.0",