Skip to content

Commit

Permalink
[AAE-7242] fix eslint warnings for content services project (#7505)
Browse files Browse the repository at this point in the history
* fix eslint warnings for content services project

* fix typing issues
  • Loading branch information
DenysVuika committed Feb 17, 2022
1 parent bca5a78 commit 9f72e30
Show file tree
Hide file tree
Showing 158 changed files with 2,601 additions and 2,712 deletions.
5 changes: 3 additions & 2 deletions lib/content-services/.eslintrc.json
Expand Up @@ -24,13 +24,14 @@
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"no-underscore-dangle": "warn",
"@typescript-eslint/member-ordering": "off",
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
"no-shadow": "warn",
"quote-props": "warn",
"object-shorthand": "warn",
"prefer-const": "warn",
"arrow-body-style": "warn",
"@angular-eslint/no-output-native": "warn",
"@angular-eslint/no-output-native": "off",
"space-before-function-paren": "warn",

"@angular-eslint/component-selector": [
Expand Down
Expand Up @@ -102,7 +102,7 @@ describe('AspectListDialogComponent', () => {
describe('Without passing node id', () => {

beforeEach(async () => {
data = <AspectListDialogComponentData> {
data = {
title: 'Title',
description: 'Description that can be longer or shorter',
overTableMessage: 'Over here',
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('AspectListDialogComponent', () => {
describe('Passing the node id', () => {

beforeEach(async () => {
data = <AspectListDialogComponentData> {
data = {
title: 'Title',
description: 'Description that can be longer or shorter',
overTableMessage: 'Over here',
Expand Down
Expand Up @@ -85,9 +85,7 @@ export class AspectListService {
private filterAspectByConfig(visibleAspectList: string[], aspectEntries: AspectEntry[]): AspectEntry[] {
let result = aspectEntries ? aspectEntries : [];
if (visibleAspectList?.length > 0 && aspectEntries) {
result = aspectEntries.filter((value) => {
return visibleAspectList.includes(value?.entry?.id);
});
result = aspectEntries.filter((value) => visibleAspectList.includes(value?.entry?.id));
}
return result;
}
Expand Down
128 changes: 64 additions & 64 deletions lib/content-services/src/lib/audit/audit.service.spec.ts
Expand Up @@ -59,34 +59,34 @@ describe('AuditService', () => {
status: 200,
contentType: 'json',
responseText: {
'list': {
'pagination': {
'count': 3,
'hasMoreItems': false,
'totalItems': 3,
'skipCount': 0,
'maxItems': 100
list: {
pagination: {
count: 3,
hasMoreItems: false,
totalItems: 3,
skipCount: 0,
maxItems: 100
},
'entries': [
entries: [
{
'entry': {
'isEnabled': true,
'name': 'Alfresco Tagging Service',
'id': 'tagging'
entry: {
isEnabled: true,
name: 'Alfresco Tagging Service',
id: 'tagging'
}
},
{
'entry': {
'isEnabled': true,
'name': 'ShareSiteAccess',
'id': 'share-site-access'
entry: {
isEnabled: true,
name: 'ShareSiteAccess',
id: 'share-site-access'
}
},
{
'entry': {
'isEnabled': true,
'name': 'alfresco-access',
'id': 'alfresco-access'
entry: {
isEnabled: true,
name: 'alfresco-access',
id: 'alfresco-access'
}
}
]
Expand All @@ -106,10 +106,10 @@ describe('AuditService', () => {
status: 200,
contentType: 'json',
responseText: {
'entry': {
'id': 'alfresco-access',
'name': 'alfresco-access',
'isEnabled': true
entry: {
id: 'alfresco-access',
name: 'alfresco-access',
isEnabled: true
}
}
});
Expand All @@ -125,49 +125,49 @@ describe('AuditService', () => {
status: 200,
contentType: 'json',
responseText: {
'list': {
'pagination': {
'count': 3,
'hasMoreItems': false,
'totalItems': 3,
'skipCount': 0,
'maxItems': 100
list: {
pagination: {
count: 3,
hasMoreItems: false,
totalItems: 3,
skipCount: 0,
maxItems: 100
},
'entries': [
entries: [
{
'entry': {
'id': '1',
'auditApplicationId': 'alfresco-access',
'createdByUser': {
'displayName': 'admin',
'id': 'admin'
entry: {
id: '1',
auditApplicationId: 'alfresco-access',
createdByUser: {
displayName: 'admin',
id: 'admin'
},
'createdAt': '2020-08-11T13:11:59.141Z',
'values': {}
createdAt: '2020-08-11T13:11:59.141Z',
values: {}
}
},
{
'entry': {
'id': '2',
'auditApplicationId': 'alfresco-access',
'createdByUser': {
'displayName': 'admin',
'id': 'admin'
entry: {
id: '2',
auditApplicationId: 'alfresco-access',
createdByUser: {
displayName: 'admin',
id: 'admin'
},
'createdAt': '2020-08-11T13:11:59.141Z',
'values': {}
createdAt: '2020-08-11T13:11:59.141Z',
values: {}
}
},
{
'entry': {
'id': '3',
'auditApplicationId': 'alfresco-access',
'createdByUser': {
'displayName': 'admin',
'id': 'admin'
entry: {
id: '3',
auditApplicationId: 'alfresco-access',
createdByUser: {
displayName: 'admin',
id: 'admin'
},
'createdAt': '2020-08-11T13:11:59.141Z',
'values': {}
createdAt: '2020-08-11T13:11:59.141Z',
values: {}
}
}
]
Expand All @@ -187,15 +187,15 @@ describe('AuditService', () => {
status: 200,
contentType: 'json',
responseText: {
'entry': {
'id': '1',
'auditApplicationId': 'alfresco-access',
'createdByUser': {
'displayName': 'admin',
'id': 'admin'
entry: {
id: '1',
auditApplicationId: 'alfresco-access',
createdByUser: {
displayName: 'admin',
id: 'admin'
},
'createdAt': '2020-08-11T13:11:59.148Z',
'values': {}
createdAt: '2020-08-11T13:11:59.148Z',
values: {}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions lib/content-services/src/lib/audit/audit.service.ts
Expand Up @@ -56,7 +56,7 @@ export class AuditService {

getAuditApp(auditApplicationId: string, opts?: any): Observable<AuditAppEntry> {
const defaultOptions = {
auditApplicationId: auditApplicationId
auditApplicationId
};
const queryOptions = Object.assign({}, defaultOptions, opts);
return from(this.auditApi.getAuditApp(queryOptions))
Expand Down Expand Up @@ -97,7 +97,7 @@ export class AuditService {

getAuditEntriesForNode(nodeId: string, opts?: any): Observable<AuditEntryPaging> {
const defaultOptions = {
nodeId: nodeId
nodeId
};
const queryOptions = Object.assign({}, defaultOptions, opts);
return from(this.auditApi.listAuditEntriesForNode(queryOptions))
Expand Down
Expand Up @@ -17,7 +17,7 @@

import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PathElementEntity, Node } from '@alfresco/js-api';
import { Node } from '@alfresco/js-api';
import { setupTestBed } from '@alfresco/adf-core';
import { fakeNodeWithCreatePermission } from '../mock';
import { DocumentListComponent, DocumentListService } from '../document-list';
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('Breadcrumb', () => {
});

it('should emit navigation event', (done) => {
const node = <PathElementEntity> { id: '-id-', name: 'name' };
const node = { id: '-id-', name: 'name' };
component.navigate.subscribe((val) => {
expect(val).toBe(node);
done();
Expand Down Expand Up @@ -112,8 +112,7 @@ describe('Breadcrumb', () => {
});

it('should update document list on click', () => {

const node = <PathElementEntity> { id: '-id-', name: 'name' };
const node = { id: '-id-', name: 'name' };
component.target = documentListComponent;

component.onRoutePathClick(node, null);
Expand Down
10 changes: 5 additions & 5 deletions lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts
Expand Up @@ -37,7 +37,7 @@ import { takeUntil } from 'rxjs/operators';
templateUrl: './breadcrumb.component.html',
styleUrls: ['./breadcrumb.component.scss'],
encapsulation: ViewEncapsulation.None,
host: { 'class': 'adf-breadcrumb' }
host: { class: 'adf-breadcrumb' }
})
export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {

Expand Down Expand Up @@ -143,13 +143,13 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {

parseRoute(node: Node): PathElementEntity[] {
if (node && node.path) {
const route = <PathElementEntity[]> (node.path.elements || []).slice();
const route = (node.path.elements || []).slice();

route.push(<PathElementEntity> {
route.push({
id: node.id,
name: node.name,
node: node
});
node
} as PathElementEntity);

const rootPos = this.getElementPosition(route, this.rootId);
if (rootPos > 0) {
Expand Down
Expand Up @@ -31,7 +31,7 @@ describe('DropdownBreadcrumb', () => {
let component: DropdownBreadcrumbComponent;
let fixture: ComponentFixture<DropdownBreadcrumbComponent>;
let documentList: DocumentListComponent;
let documentListService: DocumentListService = jasmine.createSpyObj({ 'loadFolderByNodeId': of(''), 'isCustomSourceService': false });
let documentListService: DocumentListService = jasmine.createSpyObj({ loadFolderByNodeId: of(''), isCustomSourceService: false });

setupTestBed({
imports: [
Expand All @@ -53,22 +53,22 @@ describe('DropdownBreadcrumb', () => {
fixture.destroy();
});

function openSelect() {
const openSelect = () => {
const folderIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="dropdown-breadcrumb-trigger"]');
folderIcon.click();
fixture.detectChanges();
}
};

function triggerComponentChange(fakeNodeData) {
const triggerComponentChange = (fakeNodeData) => {
component.folderNode = fakeNodeData;
component.ngOnChanges();
fixture.detectChanges();
}
};

function clickOnTheFirstOption() {
const clickOnTheFirstOption = () => {
const option: any = document.querySelector('[id^="mat-option"]');
option.click();
}
};

it('should display only the current folder name if there is no previous folders', (done) => {
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
Expand Down
Expand Up @@ -25,7 +25,7 @@ import { BreadcrumbComponent } from './breadcrumb.component';
templateUrl: './dropdown-breadcrumb.component.html',
styleUrls: ['./dropdown-breadcrumb.component.scss'],
encapsulation: ViewEncapsulation.None,
host: { 'class': 'adf-dropdown-breadcrumb' }
host: { class: 'adf-dropdown-breadcrumb' }
})
export class DropdownBreadcrumbComponent extends BreadcrumbComponent implements OnChanges {

Expand Down
Expand Up @@ -48,14 +48,14 @@ describe('ContentMetadataCardComponent', () => {
fixture = TestBed.createComponent(ContentMetadataCardComponent);
contentMetadataService = TestBed.inject(ContentMetadataService);
component = fixture.componentInstance;
node = <Node> {
node = {
aspectNames: [],
nodeType: '',
content: {},
properties: {},
createdByUser: {},
modifiedByUser: {}
};
} as Node;

component.node = node;
component.preset = preset;
Expand Down
Expand Up @@ -25,7 +25,7 @@ import { PresetConfig } from '../../interfaces/content-metadata.interfaces';
templateUrl: './content-metadata-card.component.html',
styleUrls: ['./content-metadata-card.component.scss'],
encapsulation: ViewEncapsulation.None,
host: { 'class': 'adf-content-metadata-card' }
host: { class: 'adf-content-metadata-card' }
})
export class ContentMetadataCardComponent implements OnChanges {

Expand Down

0 comments on commit 9f72e30

Please sign in to comment.