AAE-36664 additional linting rules, cleanup (#11084)

This commit is contained in:
Denys Vuika
2025-08-13 08:01:09 -04:00
committed by GitHub
parent e83c8f7fd7
commit b16e326ac3
71 changed files with 235 additions and 2994 deletions

View File

@@ -20,7 +20,6 @@ import { ContentService } from './content.service';
import { AppConfigService, AuthenticationService, RedirectAuthService, StorageService } from '@alfresco/adf-core';
import { Node, PermissionsInfo } from '@alfresco/js-api';
import { EMPTY, of } from 'rxjs';
import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('ContentService', () => {
let contentService: ContentService;
@@ -29,7 +28,6 @@ describe('ContentService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [ContentService, AuthenticationService, { provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } }]
});
authService = TestBed.inject(AuthenticationService);

View File

@@ -73,7 +73,11 @@ export class RenditionService {
return this._versionsApi;
}
constructor(private apiService: AlfrescoApiService, private translateService: TranslationService, private viewUtilsService: ViewUtilService) {}
constructor(
private readonly apiService: AlfrescoApiService,
private readonly translateService: TranslationService,
private readonly viewUtilsService: ViewUtilService
) {}
getRenditionUrl(nodeId: string, type: string, renditionExists: boolean): string {
return renditionExists && type !== RenditionService.ContentGroup.IMAGE
@@ -167,7 +171,7 @@ export class RenditionService {
}
try {
return versionId ? await this.waitNodeRendition(nodeId, renditionId, versionId) : await this.waitNodeRendition(nodeId, renditionId);
} catch (e) {
} catch {
return null;
}
} catch {

View File

@@ -54,7 +54,7 @@ const customSiteList = {
describe('DropdownSitesComponent', () => {
let loader: HarnessLoader;
let component: any;
let component: DropdownSitesComponent;
let fixture: ComponentFixture<DropdownSitesComponent>;
let element: HTMLElement;
let siteService: SitesService;
@@ -167,7 +167,7 @@ describe('DropdownSitesComponent', () => {
});
it('should load custom sites when the "siteList" input property is given a value', async () => {
component.siteList = customSiteList;
component.siteList = customSiteList as any;
fixture.detectChanges();
await fixture.whenStable();
@@ -246,7 +246,7 @@ describe('DropdownSitesComponent', () => {
fixture.whenStable().then(() => {
expect(component.selected).toBeUndefined();
expect(component.loading).toBeFalsy();
expect(component.isLoading).toBeFalsy();
done();
});
});
@@ -290,7 +290,7 @@ describe('DropdownSitesComponent', () => {
describe('No relations', () => {
beforeEach(() => {
component.relations = [];
component.relations = '';
authService = TestBed.inject(AuthenticationService);
});

View File

@@ -89,6 +89,10 @@ export class DropdownSitesComponent implements OnInit {
selected: SiteEntry = null;
MY_FILES_VALUE = '-my-';
get isLoading(): boolean {
return this.loading;
}
constructor(
private authService: AuthenticationService,
private sitesService: SitesService,

View File

@@ -161,7 +161,7 @@ export class FolderDialogComponent implements OnInit {
if (statusCode === 409) {
errorMessage = 'CORE.MESSAGES.ERRORS.EXISTENT_FOLDER';
}
} catch (err) {
} catch {
/* Do nothing, keep the original message */
}

View File

@@ -20,7 +20,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NodeDeleteDirective } from './node-delete.directive';
import { RedirectAuthService } from '@alfresco/adf-core';
import { EMPTY, of } from 'rxjs';
import { EMPTY, of, Subscription } from 'rxjs';
import { CheckAllowableOperationDirective } from './check-allowable-operation.directive';
@Component({
@@ -73,10 +73,10 @@ describe('NodeDeleteDirective', () => {
let elementWithPermanentDelete: DebugElement;
let component: TestComponent;
let componentWithPermanentDelete: TestDeletePermanentComponent;
let deleteNodeSpy: any;
let disposableDelete: any;
let deleteNodePermanentSpy: any;
let purgeDeletedNodePermanentSpy: any;
let deleteNodeSpy: jasmine.Spy;
let disposableDelete: Subscription;
let deleteNodePermanentSpy: jasmine.Spy;
let purgeDeletedNodePermanentSpy: jasmine.Spy;
beforeEach(() => {
TestBed.configureTestingModule({

View File

@@ -38,7 +38,7 @@ describe('NodeRestoreDirective', () => {
let component: TestComponent;
let trashcanApi: TrashcanApi;
let directiveInstance: NodeRestoreDirective;
let restoreNodeSpy: any;
let restoreNodeSpy: jasmine.Spy;
let translationService: TranslationService;
beforeEach(() => {
@@ -131,7 +131,7 @@ describe('NodeRestoreDirective', () => {
it('should notify on multiple fails', (done) => {
const error = { message: '{ "error": {} }' };
directiveInstance.restore.subscribe((event: any) => {
directiveInstance.restore.subscribe((event) => {
expect(event.message).toEqual('CORE.RESTORE_NODE.PARTIAL_PLURAL');
done();
});
@@ -193,7 +193,7 @@ describe('NodeRestoreDirective', () => {
restoreNodeSpy.and.returnValue(Promise.reject(error));
directiveInstance.restore.subscribe((event: any) => {
directiveInstance.restore.subscribe((event) => {
expect(event.message).toEqual('CORE.RESTORE_NODE.LOCATION_MISSING');
done();
});
@@ -205,7 +205,7 @@ describe('NodeRestoreDirective', () => {
});
it('should notify success when restore multiple nodes', (done) => {
directiveInstance.restore.subscribe((event: any) => {
directiveInstance.restore.subscribe((event) => {
expect(event.message).toEqual('CORE.RESTORE_NODE.PLURAL');
done();

View File

@@ -52,7 +52,6 @@ import {
} from '../../mock';
import { ContentTestingModule } from '../../testing/content.testing.module';
import { domSanitizerMock } from '../../testing/dom-sanitizer-mock';
import { matIconRegistryMock } from '../../testing/mat-icon-registry-mock';
import { ImageResolver } from '../data/image-resolver.model';
import { RowFilter } from '../data/row-filter.model';
import { ShareDataRow } from '../data/share-data-row.model';
@@ -64,11 +63,16 @@ import { FileAutoDownloadComponent } from './file-auto-download/file-auto-downlo
import { DocumentListComponent } from './document-list.component';
import { CustomResourcesService, DocumentListService } from '../public-api';
import { CommonModule } from '@angular/common';
import { MatIconRegistry } from '@angular/material/icon';
const mockDialog = {
open: jasmine.createSpy('open')
};
export const matIconRegistryMock = {
addSvgIconInNamespace: () => {}
} as any as MatIconRegistry;
describe('DocumentList', () => {
let loader: HarnessLoader;
let documentList: DocumentListComponent;

View File

@@ -430,7 +430,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
dataTable: DataTableComponent;
actions: ContentActionModel[] = [];
contextActionHandler: Subject<any> = new Subject();
contextActionHandler = new Subject();
data: ShareDataTableAdapter;
noPermission: boolean = false;
selection = new Array<NodeEntry>();
@@ -1051,7 +1051,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
if (JSON.parse(err.message).error.statusCode === 403) {
this.noPermission = true;
}
} catch (error) {
} catch {
/* empty */
}
}

View File

@@ -57,17 +57,3 @@ export enum ContentActionTarget {
}
export type ContentActionHandler = (obj: any, target?: any, permission?: string) => any;
export class DocumentActionModel extends ContentActionModel {
constructor(json?: any) {
super(json);
this.target = 'document';
}
}
export class FolderActionModel extends ContentActionModel {
constructor(json?: any) {
super(json);
this.target = 'folder';
}
}

View File

@@ -95,7 +95,7 @@ describe('FolderActionsService', () => {
it('should delete the folder node if there is the delete permission', () => {
spyOn(documentListService, 'deleteNode').and.callFake(
() =>
new Observable<any>((observer) => {
new Observable((observer) => {
observer.next(undefined);
observer.complete();
})
@@ -156,7 +156,7 @@ describe('FolderActionsService', () => {
it('should delete the folder node if there is the delete and others permission ', () => {
spyOn(documentListService, 'deleteNode').and.callFake(
() =>
new Observable<any>((observer) => {
new Observable((observer) => {
observer.next(undefined);
observer.complete();
})
@@ -174,7 +174,7 @@ describe('FolderActionsService', () => {
it('should support deletion only folder node', () => {
spyOn(documentListService, 'deleteNode').and.callFake(
() =>
new Observable<any>((observer) => {
new Observable((observer) => {
observer.next(undefined);
observer.complete();
})
@@ -195,7 +195,7 @@ describe('FolderActionsService', () => {
it('should require node id to delete', () => {
spyOn(documentListService, 'deleteNode').and.callFake(
() =>
new Observable<any>((observer) => {
new Observable((observer) => {
observer.next(undefined);
observer.complete();
})
@@ -211,7 +211,7 @@ describe('FolderActionsService', () => {
it('should reload target upon node deletion', async () => {
spyOn(documentListService, 'deleteNode').and.callFake(
() =>
new Observable<any>((observer) => {
new Observable((observer) => {
observer.next(undefined);
observer.complete();
})

View File

@@ -25,14 +25,13 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
import { MatButtonHarness } from '@angular/material/button/testing';
import { ReplaySubject } from 'rxjs';
import { UnitTestingUtils } from '@alfresco/adf-core';
import { MatCheckbox } from '@angular/material/checkbox';
import { By } from '@angular/platform-browser';
describe('SearchCheckListComponent', () => {
let loader: HarnessLoader;
let fixture: ComponentFixture<SearchCheckListComponent>;
let component: SearchCheckListComponent;
let unitTestingUtils: UnitTestingUtils;
beforeEach(() => {
TestBed.configureTestingModule({
@@ -41,7 +40,6 @@ describe('SearchCheckListComponent', () => {
fixture = TestBed.createComponent(SearchCheckListComponent);
component = fixture.componentInstance;
loader = TestbedHarnessEnvironment.loader(fixture);
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
component.context = {
queryFragments: {},
@@ -149,7 +147,7 @@ describe('SearchCheckListComponent', () => {
]);
fixture.detectChanges();
const checkboxes = unitTestingUtils.getAllByDirective(MatCheckbox);
const checkboxes = fixture.debugElement.queryAll(By.directive(MatCheckbox));
expect(checkboxes.length).toBe(2);
expect(checkboxes.every((checkbox) => checkbox.componentInstance.labelPosition === 'after')).toBeTrue();
});

View File

@@ -43,7 +43,7 @@ describe('TagActionsComponent', () => {
}
};
let component: any;
let component: TagActionsComponent;
let fixture: ComponentFixture<TagActionsComponent>;
let element: HTMLElement;
let tagService: TagService;
@@ -90,7 +90,7 @@ describe('TagActionsComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
const deleteButton: any = element.querySelector('#tag_delete_test1');
const deleteButton = element.querySelector<HTMLButtonElement>('#tag_delete_test1');
deleteButton.click();
expect(tagService.removeTag).toHaveBeenCalledWith('fake-node-id', '0ee933fa-57fc-4587-8a77-b787e814f1d2');
});
@@ -102,7 +102,7 @@ describe('TagActionsComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
const addButton: any = element.querySelector('#add-tag');
const addButton = element.querySelector<HTMLButtonElement>('#add-tag');
expect(addButton.disabled).toEqual(true);
});
@@ -110,7 +110,7 @@ describe('TagActionsComponent', () => {
component.nodeId = 'fake-node-id';
component.newTagName = 'test1';
await component.error.subscribe((res) => {
component.error.subscribe((res) => {
expect(res).toEqual('TAG.MESSAGES.EXIST');
});
@@ -118,7 +118,7 @@ describe('TagActionsComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
const addButton: any = element.querySelector('#add-tag');
const addButton = element.querySelector<HTMLButtonElement>('#add-tag');
addButton.click();
});
@@ -130,7 +130,7 @@ describe('TagActionsComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
const addButton: any = element.querySelector('#add-tag');
const addButton = element.querySelector<HTMLButtonElement>('#add-tag');
expect(addButton.disabled).toEqual(false);
});
});

View File

@@ -1,22 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MatIconRegistry } from '@angular/material/icon';
export const matIconRegistryMock = {
addSvgIconInNamespace: () => {}
} as any as MatIconRegistry;

View File

@@ -790,7 +790,7 @@ describe('AlfrescoViewerComponent', () => {
});
it('should Click on close button hide the viewer', (done) => {
const closeButton: any = element.querySelector('.adf-viewer-close-button');
const closeButton = element.querySelector<HTMLButtonElement>('.adf-viewer-close-button');
closeButton.click();
fixture.detectChanges();

View File

@@ -300,7 +300,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
try {
const sharedLinkEntry = await this.sharedLinksApi.getSharedLink(this.sharedLinkId);
await this.setUpSharedLinkFile(sharedLinkEntry);
} catch (error) {
} catch {
this.invalidSharedLink.next(undefined);
this.mimeType = 'invalid-link';
this.urlFileContent = 'invalid-file';
@@ -317,7 +317,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
await this.setUpNodeFile(this.nodeEntry.entry);
this.cdr.detectChanges();
}
} catch (error) {
} catch {
this.urlFileContent = 'invalid-node';
}
}
@@ -392,14 +392,14 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
const urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'pdf');
return { url: urlFileContent, mimeType: 'application/pdf' };
}
} catch (error) {
} catch {
try {
const rendition: RenditionEntry = await this.sharedLinksApi.getSharedLinkRendition(sharedId, 'imgpreview');
if (rendition.entry.status.toString() === 'CREATED') {
const urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'imgpreview');
return { url: urlFileContent, mimeType: 'image/png' };
}
} catch (renditionError) {
} catch {
return null;
}
}