Linting fixes (#9348)

* linting fixes

* lint fixes

* linting and spellcheck fixes

* code fixes
This commit is contained in:
Denys Vuika 2024-02-16 11:04:49 -05:00 committed by GitHub
parent 9b0104fcf5
commit 4c75a6748c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 100 additions and 114 deletions

View File

@ -141,7 +141,9 @@
"Whitespaces", "Whitespaces",
"xdescribe", "xdescribe",
"xsrf", "xsrf",
"BPMECM" "BPMECM",
"berseria",
"zestiria"
], ],
"dictionaries": [ "dictionaries": [
"html", "html",

View File

@ -133,23 +133,25 @@ describe('ContentService', () => {
describe('Node Icons', () => { describe('Node Icons', () => {
let node: Node; let node: Node;
node = { beforeEach(() => {
isFolder: true, node = {
isFile: false, isFolder: true,
createdByUser: { id: 'admin', displayName: 'Administrator' }, isFile: false,
modifiedAt: new Date('2017-05-24T15:08:55.640Z'), createdByUser: { id: 'admin', displayName: 'Administrator' },
nodeType: 'cm:content', modifiedAt: new Date('2017-05-24T15:08:55.640Z'),
content: { nodeType: 'cm:content',
mimeType: 'application/rtf', content: {
mimeTypeName: 'Rich Text Format', mimeType: 'application/rtf',
sizeInBytes: 14530 mimeTypeName: 'Rich Text Format',
}, sizeInBytes: 14530
createdAt: new Date('2017-05-24T15:08:55.640Z'), },
modifiedByUser: { id: 'admin', displayName: 'Administrator' }, createdAt: new Date('2017-05-24T15:08:55.640Z'),
name: 'b_txt_file.rtf', modifiedByUser: { id: 'admin', displayName: 'Administrator' },
id: 'test node 1', name: 'b_txt_file.rtf',
aspectNames: [''] id: 'test node 1',
} as Node; aspectNames: ['']
} as Node;
});
it('should resolve folder icon', () => { it('should resolve folder icon', () => {
expect(contentService.getNodeIcon(node)).toContain('assets/images/ft_ic_folder.svg'); expect(contentService.getNodeIcon(node)).toContain('assets/images/ft_ic_folder.svg');

View File

@ -16,21 +16,14 @@
*/ */
import { LayoutOrientedConfigService } from './layout-oriented-config.service'; import { LayoutOrientedConfigService } from './layout-oriented-config.service';
import { import { LayoutOrientedConfig, Property, OrganisedPropertyGroup, PropertyGroupContainer } from '../../interfaces/content-metadata.interfaces';
LayoutOrientedConfig,
Property,
OrganisedPropertyGroup,
PropertyGroupContainer
} from '../../interfaces/content-metadata.interfaces';
describe('LayoutOrientedConfigService', () => { describe('LayoutOrientedConfigService', () => {
let configService: LayoutOrientedConfigService; let configService: LayoutOrientedConfigService;
const createConfigService = (configObj: LayoutOrientedConfig) => new LayoutOrientedConfigService(configObj); const createConfigService = (configObj: LayoutOrientedConfig) => new LayoutOrientedConfigService(configObj);
describe('isGroupAllowed', () => { describe('isGroupAllowed', () => {
const testCases = [ const testCases = [
{ {
config: [], config: [],
@ -48,11 +41,15 @@ describe('LayoutOrientedConfigService', () => {
groupNameToQuery: 'berseria' groupNameToQuery: 'berseria'
}, },
{ {
config: [{ config: [
title: 'Deamons', items: [ {
{ aspect: 'zestiria', properties: '*' }, { aspect: 'berseria', properties: '*' } title: 'Deamons',
] items: [
}], { aspect: 'zestiria', properties: '*' },
{ aspect: 'berseria', properties: '*' }
]
}
],
expectation: true, expectation: true,
groupNameToQuery: 'berseria' groupNameToQuery: 'berseria'
}, },
@ -73,9 +70,7 @@ describe('LayoutOrientedConfigService', () => {
groupNameToQuery: 'phantasia' groupNameToQuery: 'phantasia'
}, },
{ {
config: [ config: [{ title: 'Deamons', includeAll: true, items: [{ aspect: 'zestiria', properties: '*' }] }],
{ title: 'Deamons', includeAll: true, items: [{ aspect: 'zestiria', properties: '*' }] }
],
expectation: true, expectation: true,
groupNameToQuery: 'phantasia' groupNameToQuery: 'phantasia'
} }
@ -93,7 +88,6 @@ describe('LayoutOrientedConfigService', () => {
}); });
describe('reorganiseByConfig', () => { describe('reorganiseByConfig', () => {
interface TestCase { interface TestCase {
name: string; name: string;
config: LayoutOrientedConfig; config: LayoutOrientedConfig;
@ -123,94 +117,81 @@ describe('LayoutOrientedConfigService', () => {
name: 'First property of a group in one item', name: 'First property of a group in one item',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
{ aspect: 'berseria', properties: ['property1'] } items: [{ aspect: 'berseria', properties: ['property1'] }]
]
} }
], ],
expectations: [ expectations: [{ title: 'First group', properties: [property1] }]
{ title: 'First group', properties: [property1] }
]
}, },
{ {
name: 'Second property of a group in one item', name: 'Second property of a group in one item',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
{ aspect: 'berseria', properties: ['property2'] } items: [{ aspect: 'berseria', properties: ['property2'] }]
]
} }
], ],
expectations: [ expectations: [{ title: 'First group', properties: [property2] }]
{ title: 'First group', properties: [property2] }
]
}, },
{ {
name: 'Properties with editable flag', name: 'Properties with editable flag',
config: [ config: [
{ {
title: 'Editable property', items: [ title: 'Editable property',
items: [
{ aspect: 'otherTales', properties: ['property5'], editable: true }, { aspect: 'otherTales', properties: ['property5'], editable: true },
{ aspect: 'otherTales', properties: ['property6'], editable: false } { aspect: 'otherTales', properties: ['property6'], editable: false }
] ]
} }
], ],
expectations: [ expectations: [{ title: 'Editable property', properties: [property5, property6] }]
{ title: 'Editable property', properties: [property5, property6] }
]
}, },
{ {
name: 'More properties from one group in one item', name: 'More properties from one group in one item',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
{ aspect: 'berseria', properties: ['property2', 'property1'] } items: [{ aspect: 'berseria', properties: ['property2', 'property1'] }]
]
} }
], ],
expectations: [ expectations: [{ title: 'First group', properties: [property2, property1] }]
{ title: 'First group', properties: [property2, property1] }
]
}, },
{ {
name: 'First property of the second group in one item', name: 'First property of the second group in one item',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
{ aspect: 'zestiria', properties: ['property4'] } items: [{ aspect: 'zestiria', properties: ['property4'] }]
]
} }
], ],
expectations: [ expectations: [{ title: 'First group', properties: [property4] }]
{ title: 'First group', properties: [property4] }
]
}, },
{ {
name: 'One-one properties from multiple groups in one item', name: 'One-one properties from multiple groups in one item',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
items: [
{ aspect: 'zestiria', properties: ['property4'] }, { aspect: 'zestiria', properties: ['property4'] },
{ aspect: 'berseria', properties: ['property1'] } { aspect: 'berseria', properties: ['property1'] }
] ]
} }
], ],
expectations: [ expectations: [{ title: 'First group', properties: [property4, property1] }]
{ title: 'First group', properties: [property4, property1] }
]
}, },
{ {
name: 'Multiple properties mixed from multiple groups in multiple items', name: 'Multiple properties mixed from multiple groups in multiple items',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
items: [
{ aspect: 'zestiria', properties: ['property4'] }, { aspect: 'zestiria', properties: ['property4'] },
{ type: 'berseria', properties: ['property1'] } { type: 'berseria', properties: ['property1'] }
] ]
}, },
{ {
title: 'Second group', items: [ title: 'Second group',
items: [
{ aspect: 'zestiria', properties: ['property3'] }, { aspect: 'zestiria', properties: ['property3'] },
{ type: 'berseria', properties: ['property2', 'property1'] }, { type: 'berseria', properties: ['property2', 'property1'] },
{ aspect: 'zestiria', properties: ['property4'] } { aspect: 'zestiria', properties: ['property4'] }
@ -226,15 +207,15 @@ describe('LayoutOrientedConfigService', () => {
name: 'Multiple properties mixed from multiple groups in multiple items with "*"', name: 'Multiple properties mixed from multiple groups in multiple items with "*"',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
items: [
{ aspect: 'zestiria', properties: '*' }, { aspect: 'zestiria', properties: '*' },
{ type: 'berseria', properties: ['property1'] } { type: 'berseria', properties: ['property1'] }
] ]
}, },
{ {
title: 'Second group', items: [ title: 'Second group',
{ type: 'berseria', properties: ['property2', 'property1'] } items: [{ type: 'berseria', properties: ['property2', 'property1'] }]
]
} }
], ],
expectations: [ expectations: [
@ -246,22 +227,22 @@ describe('LayoutOrientedConfigService', () => {
name: 'Not existing property', name: 'Not existing property',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
items: [
{ aspect: 'zestiria', properties: '*' }, { aspect: 'zestiria', properties: '*' },
{ type: 'berseria', properties: ['not-existing-property'] }, { type: 'berseria', properties: ['not-existing-property'] },
{ type: 'berseria', properties: ['property2'] } { type: 'berseria', properties: ['property2'] }
] ]
} }
], ],
expectations: [ expectations: [{ title: 'First group', properties: [property3, property4, property2] }]
{ title: 'First group', properties: [property3, property4, property2] }
]
}, },
{ {
name: 'Not existing group', name: 'Not existing group',
config: [ config: [
{ {
title: 'First group', items: [ title: 'First group',
items: [
{ aspect: 'zestiria', properties: '*' }, { aspect: 'zestiria', properties: '*' },
{ type: 'not-existing-group', properties: '*' }, { type: 'not-existing-group', properties: '*' },
{ type: 'berseria', properties: ['property2'] }, { type: 'berseria', properties: ['property2'] },
@ -269,9 +250,7 @@ describe('LayoutOrientedConfigService', () => {
] ]
} }
], ],
expectations: [ expectations: [{ title: 'First group', properties: [property3, property4, property2] }]
{ title: 'First group', properties: [property3, property4, property2] }
]
}, },
{ {
name: 'Custom Title', name: 'Custom Title',
@ -297,7 +276,6 @@ describe('LayoutOrientedConfigService', () => {
} }
] ]
} }
]; ];
testCases.forEach((testCase) => { testCases.forEach((testCase) => {
@ -308,7 +286,7 @@ describe('LayoutOrientedConfigService', () => {
expect(organisedPropertyGroups.length).toBe(testCase.expectations.length, 'Group count should match'); expect(organisedPropertyGroups.length).toBe(testCase.expectations.length, 'Group count should match');
testCase.expectations.forEach((expectation, i) => { testCase.expectations.forEach((expectation, i) => {
expect(organisedPropertyGroups[i].title).toBe(expectation.title, 'Group\'s title should match'); expect(organisedPropertyGroups[i].title).toBe(expectation.title, 'Group title should match');
expect(organisedPropertyGroups[i].properties.length).toBe( expect(organisedPropertyGroups[i].properties.length).toBe(
expectation.properties.length, expectation.properties.length,
`Property count for "${organisedPropertyGroups[i].title}" group should match.` `Property count for "${organisedPropertyGroups[i].title}" group should match.`
@ -322,23 +300,27 @@ describe('LayoutOrientedConfigService', () => {
}); });
it('should include all exclusions passed to filterExcludedPreset', () => { it('should include all exclusions passed to filterExcludedPreset', () => {
let properties: OrganisedPropertyGroup[] = [{ const properties: OrganisedPropertyGroup[] = [
name: 'propGroup', {
title: 'propGroup', name: 'propGroup',
properties: [ { name: 'property1', title: 'Custom title', editable: true } as Property, title: 'propGroup',
{ name: 'property2', title: 'Custom title', editable: true } as Property, properties: [
{ name: 'property3', title: 'Custom title', editable: true } as Property, { name: 'property1', title: 'Custom title', editable: true } as Property,
{ name: 'property4', title: 'Custom title', editable: true } as Property, { name: 'property2', title: 'Custom title', editable: true } as Property,
]}]; { name: 'property3', title: 'Custom title', editable: true } as Property,
{ name: 'property4', title: 'Custom title', editable: true } as Property
]
}
];
configService = createConfigService([ configService = createConfigService([
{ title: 'Property group', items: [ { aspect: 'berseria', properties: ['property1', 'property2', 'property3', 'property4'] } ] }, { title: 'Property group', items: [{ aspect: 'berseria', properties: ['property1', 'property2', 'property3', 'property4'] }] },
{ title: 'Exclude group 1', items: [ { exclude: ['property1'], properties: [] } ] }, { title: 'Exclude group 1', items: [{ exclude: ['property1'], properties: [] }] },
{ title: 'Exclude group 2', items: [ { exclude: ['property2'], properties: [] } ] }, { title: 'Exclude group 2', items: [{ exclude: ['property2'], properties: [] }] },
{ title: 'Exclude group 3', items: [ { exclude: ['property3'], properties: [] } ] }, { title: 'Exclude group 3', items: [{ exclude: ['property3'], properties: [] }] }
]); ]);
let result = configService.filterExcludedPreset(properties); const result = configService.filterExcludedPreset(properties);
expect(result.length).toBe(1); expect(result.length).toBe(1);
}); });

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { DownloadBodyCreate, DownloadEntry, Node } from '@alfresco/js-api'; import { DownloadBodyCreate, DownloadEntry, DownloadsApi, Node } from '@alfresco/js-api';
import { from, Observable, of, ReplaySubject, Subject } from 'rxjs'; import { from, Observable, of, ReplaySubject, Subject } from 'rxjs';
import { catchError } from 'rxjs/internal/operators/catchError'; import { catchError } from 'rxjs/internal/operators/catchError';
import { zipNode, downloadEntry } from './download-zip-data.mock'; import { zipNode, downloadEntry } from './download-zip-data.mock';
@ -40,7 +40,7 @@ class AlfrescoApiMock {
} }
export class ContentApiMock { export class ContentApiMock {
getContentUrl = (_: string, _1?: boolean, _2?: string): string => zipNode.entry.contentUrl; getContentUrl = (): string => zipNode.entry.contentUrl;
} }
class CoreMock { class CoreMock {
@ -49,19 +49,19 @@ class CoreMock {
} }
export class NodesApiMock { export class NodesApiMock {
getNode = (_: string, _2?: any): any => of(zipNode.entry); getNode = (): any => of(zipNode.entry);
} }
class DownloadsApiMock { class DownloadsApiMock extends DownloadsApi {
createDownload = (_: DownloadBodyCreate, _2?: any): Promise<DownloadEntry> => Promise.resolve(downloadEntry); createDownload = (): Promise<DownloadEntry> => Promise.resolve(downloadEntry);
getDownload = (_: string, _2?: any): Promise<DownloadEntry> => Promise.resolve(downloadEntry); getDownload = (): Promise<DownloadEntry> => Promise.resolve(downloadEntry);
cancelDownload(_: string) {} cancelDownload = () => Promise.resolve(true);
} }
export class DownloadZipMockService { export class DownloadZipMockService {
private _downloadsApi: DownloadsApiMock; private _downloadsApi: DownloadsApi;
get downloadsApi(): DownloadsApiMock { get downloadsApi(): DownloadsApi {
this._downloadsApi = this._downloadsApi ?? new DownloadsApiMock(); this._downloadsApi = this._downloadsApi ?? new DownloadsApiMock();
return this._downloadsApi; return this._downloadsApi;
} }

View File

@ -199,7 +199,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
} }
private handleError(error: any): any { private handleError(error: any): any {
let errorMessage = 'CORE.MESSAGES.ERRORS.GENERIC'; const errorMessage = 'CORE.MESSAGES.ERRORS.GENERIC';
try { try {
const { const {

View File

@ -912,15 +912,15 @@ describe('DocumentList', () => {
documentList.dataTable.columnsWidthChanged.emit(newColumnWidth as DataColumn[]); documentList.dataTable.columnsWidthChanged.emit(newColumnWidth as DataColumn[]);
expect(documentList.onColumnsWidthChange).toHaveBeenCalledWith(newColumnWidth); expect(documentList.onColumnsWidthChange).toHaveBeenCalledWith(newColumnWidth);
expect(documentList.columnsWidthChanged.emit).toHaveBeenCalledWith({'tag': 65, 'name': 77}); expect(documentList.columnsWidthChanged.emit).toHaveBeenCalledWith({tag: 65, name: 77});
}); });
it('should emit new columns visibility', () => { it('should emit new columns visibility', () => {
const newColumnsVisisbility = [{key: 'key', type: 'text', id: 'tag', isHidden: true}, {key: 'key1', type: 'text', id: 'name'}]; const newColumnsVisibility = [{key: 'key', type: 'text', id: 'tag', isHidden: true}, {key: 'key1', type: 'text', id: 'name'}];
spyOn(documentList.columnsVisibilityChanged, 'emit'); spyOn(documentList.columnsVisibilityChanged, 'emit');
documentList.onColumnsVisibilityChange(newColumnsVisisbility as DataColumn[]); documentList.onColumnsVisibilityChange(newColumnsVisibility as DataColumn[]);
expect(documentList.columnsVisibilityChanged.emit).toHaveBeenCalledWith({'tag': false}); expect(documentList.columnsVisibilityChanged.emit).toHaveBeenCalledWith({tag: false});
}); });
it('should perform folder navigation on single click', () => { it('should perform folder navigation on single click', () => {

View File

@ -62,7 +62,7 @@ export const mockSearchFilterWithDisplayedLabelsByField: SearchCategory = {
field: 'test', field: 'test',
placeholder: 'test placeholder', placeholder: 'test placeholder',
displayedLabelsByField: { displayedLabelsByField: {
'test': 'test-tab-label' test: 'test-tab-label'
} }
} }
} }

View File

@ -24,7 +24,7 @@ import { SearchWidgetSettings } from '../search/models/search-widget-settings.in
export class TabLabelsPipe implements PipeTransform { export class TabLabelsPipe implements PipeTransform {
transform(field: string, settings?: SearchWidgetSettings): string { transform(field: string, settings?: SearchWidgetSettings): string {
return settings && settings.displayedLabelsByField && settings.displayedLabelsByField[field] ? settings.displayedLabelsByField[field] : field; return settings?.displayedLabelsByField?.[field] ? settings.displayedLabelsByField[field] : field;
} }
} }

View File

@ -179,6 +179,6 @@ export class SearchDateRangeTabbedComponent implements SearchWidget, OnInit {
} }
private getDisplayLabelForField(fieldForDisplayLabel: string): string { private getDisplayLabelForField(fieldForDisplayLabel: string): string {
return this.settings && this.settings.displayedLabelsByField && this.settings.displayedLabelsByField[fieldForDisplayLabel] ? this.settings.displayedLabelsByField[fieldForDisplayLabel] : fieldForDisplayLabel; return this.settings?.displayedLabelsByField?.[fieldForDisplayLabel] ? this.settings.displayedLabelsByField[fieldForDisplayLabel] : fieldForDisplayLabel;
} }
} }