Migrate to @angular-eslint/prefer-inject and @typescript-eslint/prefer-readonly (#11665)

This commit is contained in:
Denys Vuika
2026-02-18 15:38:01 +00:00
committed by GitHub
parent f8fa996b04
commit 3f542d99ba
470 changed files with 2638 additions and 2247 deletions
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, Input, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, ViewEncapsulation, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FeaturesServiceToken, IDebugFeaturesService } from '../interfaces/features.interface';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@@ -48,16 +48,16 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class FlagsOverrideComponent {
private readonly featuresService = inject<IDebugFeaturesService>(FeaturesServiceToken);
isEnabled = false;
@Input()
size: 'small' | 'medium' | 'large' = 'medium';
constructor(
@Inject(FeaturesServiceToken)
private featuresService: IDebugFeaturesService,
changeDetectorRef: ChangeDetectorRef
) {
constructor() {
const changeDetectorRef = inject(ChangeDetectorRef);
if (this.featuresService.isEnabled$) {
this.featuresService
.isEnabled$()
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import { ChangeDetectionStrategy, Component, Inject, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, Component, ViewEncapsulation, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import {
FeaturesServiceToken,
IDebugFeaturesService,
IFeaturesService,
IWritableFeaturesService,
WritableFeaturesServiceToken,
WritableFlagChangeset
@@ -60,6 +59,9 @@ import { IconModule } from '@alfresco/adf-core';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class FlagsComponent {
private readonly featuresService = inject<IDebugFeaturesService>(FeaturesServiceToken);
private readonly writableFeaturesService = inject<IWritableFeaturesService>(WritableFeaturesServiceToken);
displayedColumns: string[] = ['icon', 'flag', 'value'];
flags$: Observable<{ fictive: boolean; flag: string; value: any }[]>;
isEnabled = false;
@@ -68,12 +70,7 @@ export class FlagsComponent {
inputValue$ = new BehaviorSubject<string>('');
showPlusButton$!: Observable<boolean>;
writableFlagChangeset: WritableFlagChangeset = {};
constructor(
@Inject(FeaturesServiceToken)
private featuresService: IDebugFeaturesService & IFeaturesService<WritableFlagChangeset>,
@Inject(WritableFeaturesServiceToken)
private writableFeaturesService: IWritableFeaturesService
) {
constructor() {
if (this.featuresService.isEnabled$) {
this.featuresService
.isEnabled$()
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Directive, Inject, Input, TemplateRef, ViewContainerRef } from '@angular/core';
import { Directive, Input, TemplateRef, ViewContainerRef, inject } from '@angular/core';
import { BehaviorSubject, combineLatest } from 'rxjs';
import { FeaturesServiceToken, FlagChangeset, IFeaturesService } from '../interfaces/features.interface';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@@ -25,19 +25,19 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
selector: '[adfForFeatures]'
})
export class FeaturesDirective {
private readonly featuresService = inject<IFeaturesService>(FeaturesServiceToken);
private readonly templateRef = inject<TemplateRef<any>>(TemplateRef);
private readonly viewContainer = inject(ViewContainerRef);
private hasView = false;
private inputUpdate$ = new BehaviorSubject([] as string[]);
private readonly inputUpdate$ = new BehaviorSubject([] as string[]);
@Input()
set adfForFeatures(feature: string[] | string) {
this.inputUpdate$.next(Array.isArray(feature) ? feature : [feature]);
}
constructor(
@Inject(FeaturesServiceToken) private featuresService: IFeaturesService,
private templateRef: TemplateRef<any>,
private viewContainer: ViewContainerRef
) {
constructor() {
combineLatest([this.featuresService.getFlags$(), this.inputUpdate$])
.pipe(takeUntilDestroyed())
.subscribe(([flags, features]: any) => this.updateView(flags, features));
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Directive, Inject, Input, TemplateRef, ViewContainerRef } from '@angular/core';
import { Directive, Input, TemplateRef, ViewContainerRef, inject } from '@angular/core';
import { BehaviorSubject, combineLatest } from 'rxjs';
import { FeaturesServiceToken, FlagChangeset, IFeaturesService } from '../interfaces/features.interface';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@@ -25,19 +25,19 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
selector: '[adfNotForFeatures]'
})
export class NotFeaturesDirective {
private readonly featuresService = inject<IFeaturesService>(FeaturesServiceToken);
private readonly templateRef = inject<TemplateRef<any>>(TemplateRef);
private readonly viewContainer = inject(ViewContainerRef);
private hasView = false;
private inputUpdate$ = new BehaviorSubject([] as string[]);
private readonly inputUpdate$ = new BehaviorSubject([] as string[]);
@Input()
set adfNotForFeatures(feature: string[] | string) {
this.inputUpdate$.next(Array.isArray(feature) ? feature : [feature]);
}
constructor(
@Inject(FeaturesServiceToken) private featuresService: IFeaturesService,
private templateRef: TemplateRef<any>,
private viewContainer: ViewContainerRef
) {
constructor() {
combineLatest([this.featuresService.getFlags$(), this.inputUpdate$])
.pipe(takeUntilDestroyed())
.subscribe(([flags, features]: any) => this.updateView(flags, features));
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Inject, Injectable, inject } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { FeaturesServiceToken, IFeaturesService } from '../interfaces/features.interface';
import { Route } from '@angular/router';
import { Observable } from 'rxjs';
@@ -24,7 +24,7 @@ export const isFeatureOff = (flag: string) => () => inject(FeaturesServiceToken)
@Injectable({ providedIn: 'root' })
export class IsFeatureOff {
constructor(@Inject(FeaturesServiceToken) private featuresServiceToken: IFeaturesService) {}
private readonly featuresServiceToken = inject<IFeaturesService>(FeaturesServiceToken);
canMatch(route: Route): Observable<boolean> {
return this.featuresServiceToken.isOff$(route?.data?.['feature']);
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Inject, Injectable, inject } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { FeaturesServiceToken, IFeaturesService } from '../interfaces/features.interface';
import { Route } from '@angular/router';
import { Observable } from 'rxjs';
@@ -24,7 +24,7 @@ export const isFeatureOn = (flag: string) => () => inject(FeaturesServiceToken).
@Injectable({ providedIn: 'root' })
export class IsFeatureOn {
constructor(@Inject(FeaturesServiceToken) private featuresServiceToken: IFeaturesService) {}
private readonly featuresServiceToken = inject<IFeaturesService>(FeaturesServiceToken);
canMatch(route: Route): Observable<boolean> {
return this.featuresServiceToken.isOn$(route?.data?.['feature']);
@@ -15,14 +15,14 @@
* limitations under the License.
*/
import { Inject, Injectable, Optional, inject } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { FlagsOverrideToken } from '../interfaces/features.interface';
export const isFlagsOverrideOn = () => () => inject(FlagsOverrideToken) ?? false;
@Injectable({ providedIn: 'root' })
export class IsFlagsOverrideOn {
constructor(@Optional() @Inject(FlagsOverrideToken) private devToolsToken: boolean) {}
private readonly devToolsToken = inject(FlagsOverrideToken, { optional: true });
canMatch(): boolean {
return !!this.devToolsToken;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Inject, Injectable, Optional } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { BehaviorSubject, Observable, combineLatest } from 'rxjs';
import { filter, switchMap } from 'rxjs/operators';
import {
@@ -26,12 +26,15 @@ import {
WritableFeaturesServiceToken,
WritableFeaturesServiceConfigToken,
WritableFeaturesServiceConfig,
FlagSet,
IWritableFeaturesService
FlagSet
} from '../interfaces/features.interface';
@Injectable()
export class DebugFeaturesService implements IDebugFeaturesService {
private readonly overriddenFeaturesService = inject<IFeaturesService>(OverridableFeaturesServiceToken);
private readonly writableFeaturesService = inject(WritableFeaturesServiceToken);
private readonly config = inject<WritableFeaturesServiceConfig>(WritableFeaturesServiceConfigToken, { optional: true });
private readonly isInDebugModeSubject = new BehaviorSubject<boolean>(false);
private readonly isInDebugMode$ = this.isInDebugModeSubject.asObservable();
private readonly initSubject = new BehaviorSubject<boolean>(false);
@@ -40,11 +43,7 @@ export class DebugFeaturesService implements IDebugFeaturesService {
return `${this.config?.storageKey || 'feature-flags'}-override`;
}
constructor(
@Inject(OverridableFeaturesServiceToken) private overriddenFeaturesService: IFeaturesService,
@Inject(WritableFeaturesServiceToken) private writableFeaturesService: IFeaturesService & IWritableFeaturesService,
@Optional() @Inject(WritableFeaturesServiceConfigToken) private config?: WritableFeaturesServiceConfig
) {
constructor() {
this.init();
combineLatest({
@@ -15,12 +15,13 @@
* limitations under the License.
*/
import { ApplicationRef, Inject, Injectable } from '@angular/core';
import { ApplicationRef, Injectable, inject } from '@angular/core';
import { FeaturesServiceToken, FlagSet } from '../interfaces/features.interface';
import { DebugFeaturesService } from './debug-features.service';
@Injectable()
export class QaFeaturesHelper {
constructor(private applicationRef: ApplicationRef, @Inject(FeaturesServiceToken) private debugFeaturesService: DebugFeaturesService) {}
private readonly applicationRef = inject(ApplicationRef);
private readonly debugFeaturesService = inject<DebugFeaturesService>(FeaturesServiceToken);
isOn(key: string): boolean {
let isOn = false;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Inject, Injectable, Optional } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { BehaviorSubject, combineLatest, Observable, of } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import {
@@ -31,12 +31,14 @@ import { FlagSetParser } from './flagset.parser';
@Injectable({ providedIn: 'root' })
export class StorageFeaturesService implements IFeaturesService, IWritableFeaturesService {
private readonly config = inject<WritableFeaturesServiceConfig>(WritableFeaturesServiceConfigToken, { optional: true });
private currentFlagState: WritableFlagChangeset = {};
private readonly flags = new BehaviorSubject<WritableFlagChangeset>({});
private readonly flags$ = this.flags.asObservable();
private readonly initSubject = new BehaviorSubject<boolean>(false);
constructor(@Optional() @Inject(WritableFeaturesServiceConfigToken) private config?: WritableFeaturesServiceConfig) {
constructor() {
combineLatest({
flags: this.flags,
init: this.waitForInitializationToFinish()