Skip to content

Commit

Permalink
#19837 Lint updates part one (#1890)
Browse files Browse the repository at this point in the history
* fix lint - first

* progress

* add new types

* progress

* add types

* add types

* progress

* feedback

* progress

* fix crud service type

* add types

* add types

* paginator service

* dot workflow event handler service

* remove any

* feedback

* clean up
  • Loading branch information
rjvelazco authored Feb 18, 2022
1 parent c8554e3 commit 4bb9725
Show file tree
Hide file tree
Showing 76 changed files with 536 additions and 348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ export class AddToBundleService {

/**
* Get bundle items
* @returns Observable<any[]>
* @return {*} {Observable<DotBundle[]>}
* @memberof AddToBundleService
*/
getBundles(): Observable<any[]> {
return <any>this.currentUser.getCurrentUser().pipe(
getBundles(): Observable<DotBundle[]> {
return this.currentUser.getCurrentUser().pipe(
mergeMap((user: DotCurrentUser) => {
return this.coreWebService
.requestView({
url: `${this.bundleUrl}/${user.userId}`
})
.pipe(pluck('bodyJsonObject', 'items'));
})
);
) as Observable<DotBundle[]>;
}

/**
Expand All @@ -58,6 +58,6 @@ export class AddToBundleService {
method: 'POST',
url: this.addToBundleUrl
})
.pipe(map((res: any) => <DotAjaxActionResponseView>res));
.pipe(map((res: DotAjaxActionResponseView) => res));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('DotAppsService', () => {
const appKey = '1';
const hostId = 'abc';
const params: DotAppsSaveData = {
name: { hidden: 'false', value: 'test' }
name: { hidden: false, value: 'test' }
};
const url = `v1/apps/${appKey}/${hostId}`;

Expand All @@ -238,8 +238,8 @@ describe('DotAppsService', () => {
});

it('should throw error on Save a specific app and handle it', () => {
const params = {
name: { hidden: 'false', value: 'test' }
const params: DotAppsSaveData = {
name: { hidden: false, value: 'test' }
};
const error404 = mockResponseView(400);
spyOn(dotHttpErrorManagerService, 'handle').and.callThrough();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class DotContentTypesInfoService {

// tslint:disable-next-line:cyclomatic-complexity
private getItem(type: string, prop: string): string {
let result: any;
let result: string;
// TODO: Remove this when set Material Design icons on NgPrime native components - BEGIN
let oldValue = false;
if (type.indexOf('_old') > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { pluck } from 'rxjs/operators';
import { CoreWebService } from '@dotcms/dotcms-js';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { DotContentletLockResponse } from '@models/contentlet/contentlet-locker.model';

@Injectable()
export class DotContentletLockerService {
Expand All @@ -14,7 +15,7 @@ export class DotContentletLockerService {
* @returns Observable<any>
* @memberof PageViewService
*/
lock(inode: string): Observable<any> {
lock(inode: string): Observable<DotContentletLockResponse> {
return this.coreWebService
.requestView({
method: 'PUT',
Expand All @@ -30,7 +31,7 @@ export class DotContentletLockerService {
* @returns Observable<any>
* @memberof PageViewService
*/
unlock(inode: string): Observable<any> {
unlock(inode: string): Observable<DotContentletLockResponse> {
return this.coreWebService
.requestView({
method: 'PUT',
Expand Down
14 changes: 7 additions & 7 deletions apps/dotcms-ui/src/app/api/services/dot-crud/dot-crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class DotCrudService {
* @returns Observable<any>
* @memberof CrudService
*/
public postData(baseUrl: string, data: any): Observable<any> {
public postData<T, K>(baseUrl: string, data: K): Observable<T> {
return this.coreWebService
.requestView({
body: data,
Expand All @@ -38,9 +38,9 @@ export class DotCrudService {
* @returns Observable<any>
* @memberof CrudService
*/
public putData(baseUrl: string, data: any): Observable<any> {
public putData<T>(baseUrl: string, data: unknown): Observable<T> {
return this.coreWebService
.requestView({
.requestView<T>({
body: data,
method: 'PUT',
url: `${baseUrl}`
Expand All @@ -57,9 +57,9 @@ export class DotCrudService {
* @returns {Observable<any>}
* @memberof DotCrudService
*/
getDataById(baseUrl: string, id: string, pick = 'entity'): Observable<any> {
getDataById<T>(baseUrl: string, id: string, pick = 'entity'): Observable<T> {
return this.coreWebService
.requestView({
.requestView<T>({
url: `${baseUrl}/id/${id}`
})
.pipe(pluck(pick));
Expand All @@ -73,9 +73,9 @@ export class DotCrudService {
* @returns Observable<any>
* @memberof CrudService
*/
delete(baseUrl: string, id: string): Observable<any> {
delete<T>(baseUrl: string, id: string): Observable<T> {
return this.coreWebService
.requestView({
.requestView<T>({
method: 'DELETE',
url: `${baseUrl}/${id}`
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export class DotCurrentUserService {
*/
getCurrentUser(): Observable<DotCurrentUser> {
return this.coreWebService
.request({
.request<DotCurrentUser>({
url: this.currentUsersUrl
})
.pipe(map((res: any) => <DotCurrentUser>res));
.pipe(map((res: DotCurrentUser) => res));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DotEventsService {
*
* @param DotEvent dotEvent
*/
notify(name: string, data?: any): void {
notify(name: string, data?: unknown): void {
this.subject.next({
name: name,
data: data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class DotHttpErrorManagerService {
return of(result);
}

private callErrorHandler(response: HttpErrorResponse | any): boolean {
private callErrorHandler(response: HttpErrorResponse): boolean {
const code = response.status;

return code === HttpCode.FORBIDDEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { pluck, map, take } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { CoreWebService } from '@dotcms/dotcms-js';
import { Observable, Subject, BehaviorSubject } from 'rxjs';
import { DotLicense } from '@dotcms/dotcms-models';

export interface DotUnlicensedPortletData {
icon: string;
Expand Down Expand Up @@ -107,7 +108,7 @@ export class DotLicenseService {
return !!urlMatch.length;
}

private getLicense(): Observable<any> {
private getLicense(): Observable<DotLicense> {
return this.coreWebService
.requestView({
url: this.licenseURL
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcms-ui/src/app/api/services/dot-menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class DotMenuService {
*/
getUrlById(id: string): Observable<string> {
return this.getMenuItems().pipe(
filter((res: any) => !res.angular && res.id === id),
filter((res: DotMenuItem) => !res.angular && res.id === id),
first(),
pluck('url')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class DotPropertiesService {
getKeyAsList(key: string): Observable<string[]> {
const finalKey = `list:${key}`;
return this.coreWebService
.requestView<{ [key: string]: any }>({
.requestView<{ [key: string]: string[] }>({
url: `/api/v1/configuration/config?keys=${finalKey}`
})
.pipe(take(1), pluck('entity', key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class DotTemplatesService {
*/
copy(identifier: string): Observable<DotTemplate> {
const url = `${TEMPLATE_API_URL}${identifier}/_copy`;
return this.request<any>({ method: 'PUT', url });
return this.request<DotTemplate>({ method: 'PUT', url });
}

private request<T>(options: DotRequestOptionsArgs): Observable<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ describe('DotUiColorsService', () => {
service = injector.get(DotUiColorsService);

setPropertySpy = jasmine.createSpy('setProperty');
spyOn<any>(document, 'querySelector').and.returnValue({
spyOn(document as Document, 'querySelector').and.returnValue({
style: {
setProperty: setPropertySpy
}
});
} as HTMLElement);

spyOn<any>(window, 'getComputedStyle').and.returnValue({
spyOn(window as Window, 'getComputedStyle').and.returnValue({
getPropertyValue: (cssVar: string) => {
const map = {
'--color-main': '#C336E5',
Expand All @@ -29,7 +29,7 @@ describe('DotUiColorsService', () => {
};
return map[cssVar];
}
});
} as CSSStyleDeclaration);
});

it('should set all colors', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DotWizardInput } from '@models/dot-wizard-input/dot-wizard-input.model'
@Injectable()
export class DotWizardService {
private input: Subject<DotWizardInput> = new Subject<DotWizardInput>();
private output: Subject<{ [key: string]: string }> = new Subject<{ [key: string]: string }>();
private output: Subject<Record<string, unknown>> = new Subject<{ [key: string]: string }>();

get showDialog$(): Observable<DotWizardInput> {
return this.input.asObservable();
Expand All @@ -26,8 +26,8 @@ export class DotWizardService {
* @returns Observable<{ [key: string]: string }>
* @memberof DotWizardService
*/
open(data: DotWizardInput): Observable<{ [key: string]: string }> {
open<T = { [key: string]: string }>(data: DotWizardInput): Observable<T> {
this.input.next(data);
return this.output.asObservable();
return this.output.asObservable() as Observable<T>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DotActionBulkResult } from '@models/dot-action-bulk-result/dot-action-b

interface DotActionRequestOptions {
contentType?: string;
data: { [key: string]: any };
data: { [key: string]: string };
action: ActionToFire;
}

Expand All @@ -28,13 +28,13 @@ export class DotWorkflowActionsFireService {
* @param {string} inode
* @param {string} actionId
* @param {{ [key: string]: string }} data
* @returns Observable<any> // contentlet
* @returns Observable<DotCMSContentlet> // contentlet
* @memberof DotWorkflowActionsFireService
*/
fireTo(
fireTo<T = { [key: string]: string }>(
inode: string,
actionId: string,
data?: { [key: string]: string }
data?: T
): Observable<DotCMSContentlet> {
return this.coreWebService
.requestView({
Expand All @@ -49,7 +49,7 @@ export class DotWorkflowActionsFireService {
* Fire a workflow action over a contentlet
*
* @param {DotActionBulkRequestOptions} data
* @returns Observable<any> // contentlet
* @returns Observable<DotActionBulkResult> // contentlet
* @memberof DotWorkflowActionsFireService
*/
bulkFire(data: DotActionBulkRequestOptions): Observable<DotActionBulkResult> {
Expand All @@ -66,12 +66,12 @@ export class DotWorkflowActionsFireService {
* Fire a "NEW" action over the content type received with the specified data
*
* @param {contentType} string
* @param {[key: string]: any} data
* @param {[key: string]: string} data
* @returns Observable<T>
*
* @memberof DotWorkflowActionsFireService
*/
newContentlet<T>(contentType: string, data: { [key: string]: any }): Observable<T> {
newContentlet<T>(contentType: string, data: { [key: string]: string }): Observable<T> {
return this.request<T>({ contentType, data, action: ActionToFire.NEW });
}

Expand All @@ -80,11 +80,11 @@ export class DotWorkflowActionsFireService {
*
* @template T
* @param {string} contentType
* @param {{ [key: string]: any }} data
* @param {{ [key: string]: string}} data
* @returns {Observable<T>}
* @memberof DotWorkflowActionsFireService
*/
publishContentlet<T>(contentType: string, data: { [key: string]: any }): Observable<T> {
publishContentlet<T>(contentType: string, data: { [key: string]: string }): Observable<T> {
return this.request<T>({
contentType,
data,
Expand All @@ -96,11 +96,11 @@ export class DotWorkflowActionsFireService {
*
* @template T
* @param {string} contentType
* @param {{ [key: string]: any }} data
* @param {{ [key: string]: unknown}} data
* @return {*} {Observable<T>}
* @memberof DotWorkflowActionsFireService
*/
saveContentlet<T>(data: { [key: string]: any }): Observable<T> {
saveContentlet<T>(data: { [key: string]: string }): Observable<T> {
return this.request<T>({
data,
action: ActionToFire.EDIT
Expand All @@ -112,13 +112,13 @@ export class DotWorkflowActionsFireService {
*
* @template T
* @param {string} contentType
* @param {{ [key: string]: any }} data
* @param {{ [key: string]: unknown}} data
* @returns {Observable<T>}
* @memberof DotWorkflowActionsFireService
*/
publishContentletAndWaitForIndex<T>(
contentType: string,
data: { [key: string]: any }
data: { [key: string]: string }
): Observable<T> {
return this.publishContentlet(contentType, {
...data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { DotActionBulkRequestOptions } from '@models/dot-action-bulk-request-opt
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { DotFormatDateService } from '@services/dot-format-date-service';
import { DotFormatDateServiceMock } from '@dotcms/app/test/format-date-service.mock';
import { DotWorkflowPayload, DotProcessedWorkflowPayload } from '@dotcms/dotcms-models';

const mockWAEvent: DotCMSWorkflowActionEvent = {
workflow: mockWorkflowsActions[0],
Expand Down Expand Up @@ -74,7 +75,7 @@ const mockWizardInput: DotWizardInput = {
steps: mockWizardSteps
};

const mockWizardOutputData = {
const mockWizardOutputData: DotWorkflowPayload = {
assign: '654b0931-1027-41f7-ad4d-173115ed8ec1',
comments: 'ds',
pathToMove: '/test/',
Expand All @@ -86,7 +87,7 @@ const mockWizardOutputData = {
timezoneId: 'America/Costa_Rica'
};

const mockWizardOutputTransformedData: { [key: string]: any } = {
const mockWizardOutputTransformedData: DotProcessedWorkflowPayload = {
assign: '654b0931-1027-41f7-ad4d-173115ed8ec1',
comments: 'ds',
expireDate: '2020-08-11',
Expand Down
Loading

0 comments on commit 4bb9725

Please sign in to comment.