@dsivd/prestations-ng 19.2.0-beta.25 → 19.2.0-beta.26

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/CHANGELOG.md CHANGED
@@ -192,6 +192,10 @@ Please check the [UPGRADING_V19.md](UPGRADING_V19.md) guide for more information
192
192
  only takes strings, numbers, booleans, `null`, `undefined`, `any` and `RegExp`: a signal not called
193
193
  (`` `api/${this.reference}` ``) or an object turned into text by its `toString()` is reported. See
194
194
  [ESLINT_PLUGIN.md](ESLINT_PLUGIN.md#the-typescript-counterpart).
195
+ - 🚨 ESLint: `configs.tsRecommended` enables `@typescript-eslint/no-useless-constructor` (since 19.2.0-beta.26). A
196
+ constructor only passing its parameters to `super()`, typically the `constructor() { super(); }` left once the
197
+ services are injected with `inject()`, is reported: remove it. See
198
+ [ESLINT_PLUGIN.md](ESLINT_PLUGIN.md#a-constructor-only-calling-super) for a parent with a `protected` constructor.
195
199
  - 🚨 `AbstractPageComponent`: `form` is now a signal (`WritableSignal<T | null | undefined>`). Read it with `form()`,
196
200
  never modify its value in place: write it with the new `patchForm(path, value)`
197
201
  (`[model]="form.firstName" (modelChange)="patchForm(['firstName'], $event)"`), `form.set()` or `form.update()`. A
package/ESLINT_PLUGIN.md CHANGED
@@ -62,9 +62,11 @@ here they bring:
62
62
  stylistic, `angular-eslint` recommended, and for templates its accessibility set;
63
63
  - the house style — naming and selector conventions, import ordering
64
64
  (`simple-import-sort`, `import-x`), rxjs conventions, the signal rules of
65
- `angular-eslint` (`no-uncalled-signals`, `prefer-signals`, `prefer-signal-model`), and
65
+ `angular-eslint` (`no-uncalled-signals`, `prefer-signals`, `prefer-signal-model`),
66
66
  `@typescript-eslint/restrict-template-expressions` (see
67
- [The TypeScript counterpart](#the-typescript-counterpart)).
67
+ [The TypeScript counterpart](#the-typescript-counterpart)), and
68
+ `@typescript-eslint/no-useless-constructor` (see
69
+ [A constructor only calling `super()`](#a-constructor-only-calling-super)).
68
70
 
69
71
  Use `tsRules` / `templateRules` instead when a project supplies its own style and only wants
70
72
  the rules of this library. They register the plugin and nothing else, so you keep control of
@@ -428,3 +430,18 @@ called is reported, as is an object turned into text by its `toString()`. With
428
430
  ```ts
429
431
  '@typescript-eslint/restrict-template-expressions': 'error',
430
432
  ```
433
+
434
+ ## A constructor only calling `super()`
435
+
436
+ `configs.tsRecommended` enables `@typescript-eslint/no-useless-constructor`: a constructor
437
+ which only passes its parameters to `super()` is reported, typically the
438
+ `constructor() { super(); }` left once the services are injected with `inject()`. Remove it:
439
+ the class inherits the constructor of its parent. A `protected` or `private` constructor is
440
+ not reported, nor one giving other arguments to its parent (`super(Type.SUBSIDY)`).
441
+
442
+ When the removal gives `Cannot assign a 'protected' constructor type to a 'public'
443
+ constructor type` (TS2322 on the `component` of a route, TS2345 on
444
+ `TestBed.createComponent()`), the parent declares a `protected constructor()`, which the
445
+ class now inherits. Remove that one too when the parent is `abstract`: it already can't be
446
+ instantiated. Otherwise keep the constructor of the class, with an `eslint-disable-next-line`
447
+ saying why.
@@ -92,6 +92,11 @@ const tsRecommended = (plugin) => [
92
92
  // off here — @typescript-eslint/no-shadow handles it correctly for TS
93
93
  'no-shadow': 'off',
94
94
  '@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
95
+ // a constructor only passing its parameters to super(), e.g. the
96
+ // `constructor() { super(); }` left once the services are injected with
97
+ // inject(); off here — the core rule ignores the parameter properties
98
+ 'no-useless-constructor': 'off',
99
+ '@typescript-eslint/no-useless-constructor': 'error',
95
100
  '@typescript-eslint/no-unused-vars': [
96
101
  'error',
97
102
  {
package/package.json CHANGED
@@ -39,7 +39,7 @@
39
39
  "ng-update": {
40
40
  "migrations": "./schematics/migration-collection.json"
41
41
  },
42
- "version": "19.2.0-beta.25",
42
+ "version": "19.2.0-beta.26",
43
43
  "module": "fesm2022/dsivd-prestations-ng.mjs",
44
44
  "typings": "types/dsivd-prestations-ng.d.ts",
45
45
  "exports": {
@@ -126,6 +126,21 @@ describe('eslint configs', () => {
126
126
  );
127
127
  });
128
128
 
129
+ describe('tsRecommended', () => {
130
+ // The last entry setting a rule wins, as in ESLint
131
+ const rules = Object.assign(
132
+ {},
133
+ ...configs.tsRecommended.map((entry) => entry.rules ?? {}),
134
+ );
135
+
136
+ it('should report a constructor only calling super() with the rule of typescript-eslint', () => {
137
+ expect(rules['@typescript-eslint/no-useless-constructor']).toBe(
138
+ 'error',
139
+ );
140
+ expect(rules['no-useless-constructor']).toBe('off');
141
+ });
142
+ });
143
+
129
144
  describe('specTsRecommended', () => {
130
145
  const rulesOf = (config) =>
131
146
  Object.assign({}, ...config.map((entry) => entry.rules ?? {}));
@@ -92,6 +92,11 @@ const tsRecommended = (plugin) => [
92
92
  // off here — @typescript-eslint/no-shadow handles it correctly for TS
93
93
  'no-shadow': 'off',
94
94
  '@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
95
+ // a constructor only passing its parameters to super(), e.g. the
96
+ // `constructor() { super(); }` left once the services are injected with
97
+ // inject(); off here — the core rule ignores the parameter properties
98
+ 'no-useless-constructor': 'off',
99
+ '@typescript-eslint/no-useless-constructor': 'error',
95
100
  '@typescript-eslint/no-unused-vars': [
96
101
  'error',
97
102
  {