Skip to content

Commit

Permalink
fix eslint warnigs for core project (#7506)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika committed Feb 17, 2022
1 parent 5b7f255 commit bca5a78
Show file tree
Hide file tree
Showing 246 changed files with 5,128 additions and 5,066 deletions.
11 changes: 6 additions & 5 deletions lib/core/.eslintrc.json
Expand Up @@ -21,16 +21,17 @@
],
"rules": {
"jsdoc/newline-after-description": "warn",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"no-underscore-dangle": ["warn", { "allowAfterThis": true }],
"@typescript-eslint/prefer-for-of": "off",
"@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 @@ -105,7 +106,7 @@
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-positive-tabindex": "error",

"@angular-eslint/template/no-negated-async": "warn"
"@angular-eslint/template/no-negated-async": "off"
}
}
]
Expand Down
Expand Up @@ -52,22 +52,22 @@ describe('AboutGithubLinkComponent', () => {
expect(titleElement.innerText).toEqual('mock-application-name');
});

it('should display version', async() => {
it('should display version', async () => {
component.version = aboutGithubDetails.version;
fixture.detectChanges();
await fixture.whenStable();
const version = fixture.nativeElement.querySelector('[data-automation-id="adf-github-version"]');
expect(version.innerText).toEqual('ABOUT.VERSION: 0.0.7');
});

it('should display adf github link as default if url is not specified', async() => {
it('should display adf github link as default if url is not specified', async () => {
fixture.detectChanges();
await fixture.whenStable();
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defualrUrl);
});

it('should display the github link', async() => {
it('should display the github link', async () => {
component.url = aboutGithubDetails.url;
fixture.detectChanges();
await fixture.whenStable();
Expand Down
Expand Up @@ -40,8 +40,8 @@ describe('AboutServerSettingsComponent', () => {
component = fixture.componentInstance;
appConfigService = TestBed.inject(AppConfigService);
appConfigService.config = Object.assign(appConfigService.config, {
'ecmHost': aboutGithubDetails.ecmHost,
'bpmHost': aboutGithubDetails.bpmHost
ecmHost: aboutGithubDetails.ecmHost,
bpmHost: aboutGithubDetails.bpmHost
});
fixture.detectChanges();
});
Expand All @@ -50,7 +50,7 @@ describe('AboutServerSettingsComponent', () => {
fixture.destroy();
});

it('should fetch process and content hosts from the app.config.json file', async() => {
it('should fetch process and content hosts from the app.config.json file', async () => {
await fixture.whenStable();
expect(component.bpmHost).toEqual(aboutGithubDetails.bpmHost);
expect(component.ecmHost).toEqual(aboutGithubDetails.ecmHost);
Expand Down
24 changes: 9 additions & 15 deletions lib/core/about/about.component.ts
Expand Up @@ -73,9 +73,7 @@ export class AboutComponent implements OnInit {
this.dependencies = this.pkg?.dependencies;

if (this.dependencies) {
const alfrescoPackages = Object.keys(this.dependencies).filter((val) => {
return new RegExp(this.regexp).test(val);
});
const alfrescoPackages = Object.keys(this.dependencies).filter((val) => new RegExp(this.regexp).test(val));

alfrescoPackages.forEach((val) => {
this.dependencyEntries.push({
Expand All @@ -97,20 +95,16 @@ export class AboutComponent implements OnInit {
this.discovery.getEcmProductInfo().subscribe((repository) => {
this.repository = repository;

this.statusEntries = Object.keys(repository.status).map((key) => {
return {
property: key,
value: repository.status[key]
};
});
this.statusEntries = Object.keys(repository.status).map((key) => ({
property: key,
value: repository.status[key]
}));

if (repository.license) {
this.licenseEntries = Object.keys(repository.license).map((key) => {
return {
property: key,
value: repository.license[key]
};
});
this.licenseEntries = Object.keys(repository.license).map((key) => ({
property: key,
value: repository.license[key]
}));
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/about/about.mock.ts
Expand Up @@ -22,7 +22,7 @@ export const mockDependencies = {
'@angular/mock-services': '8.0.0'
};

export const mockPlugins = <any> [
export const mockPlugins = [
{
$name: 'plugin1',
$version: '1.0.0',
Expand Down
2 changes: 1 addition & 1 deletion lib/core/app-config/app-config.service.spec.ts
Expand Up @@ -44,7 +44,7 @@ describe('AppConfigService', () => {
name: 'Custom Name'
},
files: {
'excluded': ['excluded']
excluded: ['excluded']
},
logLevel: 'silent',
alfrescoRepositoryName: 'alfresco-1'
Expand Down
10 changes: 9 additions & 1 deletion lib/core/app-config/app-config.service.ts
Expand Up @@ -23,6 +23,7 @@ import { map, distinctUntilChanged, take } from 'rxjs/operators';
import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions';

/* spellchecker: disable */
// eslint-disable-next-line no-shadow
export enum AppConfigValues {
APP_CONFIG_LANGUAGES_KEY = 'languages',
PROVIDERS = 'providers',
Expand All @@ -44,6 +45,7 @@ export enum AppConfigValues {
NOTIFY_DURATION = 'notificationDefaultDuration'
}

// eslint-disable-next-line no-shadow
export enum Status {
INIT = 'init',
LOADING = 'loading',
Expand Down Expand Up @@ -81,6 +83,7 @@ export class AppConfigService {

/**
* Requests notification of a property value when it is loaded.
*
* @param property The desired property value
* @returns Property value, when loaded
*/
Expand All @@ -94,6 +97,7 @@ export class AppConfigService {

/**
* Gets the value of a named property.
*
* @param key Name of the property
* @param defaultValue Value to return if the key is not found
* @returns Value of the property
Expand All @@ -119,11 +123,12 @@ export class AppConfigService {
return defaultValue;
}

return <T> result;
return result;
}

/**
* Gets the location.protocol value.
*
* @returns The location.protocol string
*/
getLocationProtocol(): string {
Expand All @@ -132,6 +137,7 @@ export class AppConfigService {

/**
* Gets the location.hostname property.
*
* @returns Value of the property
*/
getLocationHostname(): string {
Expand All @@ -140,6 +146,7 @@ export class AppConfigService {

/**
* Gets the location.port property.
*
* @param prefix Text added before port value
* @returns Port with prefix
*/
Expand Down Expand Up @@ -172,6 +179,7 @@ export class AppConfigService {

/**
* Loads the config file.
*
* @returns Notification when loading is complete
*/
load(): Promise<any> {
Expand Down
4 changes: 2 additions & 2 deletions lib/core/app-config/debug-app-config.service.ts
Expand Up @@ -30,11 +30,11 @@ export class DebugAppConfigService extends AppConfigService {
/** @override */
get<T>(key: string, defaultValue?: T): T {
if (key === AppConfigValues.OAUTHCONFIG) {
return <T> (JSON.parse(this.storage.getItem(key)) || super.get<T>(key, defaultValue));
return (JSON.parse(this.storage.getItem(key)) || super.get<T>(key, defaultValue));
} else if (key === AppConfigValues.APPLICATION) {
return undefined;
} else {
return <T> (<any> this.storage.getItem(key) || super.get<T>(key, defaultValue));
return (this.storage.getItem(key) as any || super.get<T>(key, defaultValue));
}
}
}
Expand Up @@ -28,11 +28,12 @@ describe('CardViewArrayItemComponent', () => {
let component: CardViewArrayItemComponent;
let fixture: ComponentFixture<CardViewArrayItemComponent>;

const mockData = <CardViewArrayItem[]> [
const mockData = [
{ icon: 'person', value: 'Zlatan' },
{ icon: 'group', value: 'Lionel Messi' },
{ icon: 'person', value: 'Mohamed' },
{ icon: 'person', value: 'Ronaldo' }];
{ icon: 'person', value: 'Ronaldo' }
] as CardViewArrayItem[];

const mockDefaultProps = {
label: 'Array of items',
Expand Down
Expand Up @@ -184,15 +184,15 @@ describe('CardViewBoolItemComponent', () => {
spyOn(cardViewUpdateService, 'update');
const property = { ... component.property };

component.changed(<MatCheckboxChange> { checked: true });
component.changed({ checked: true } as MatCheckboxChange);

expect(cardViewUpdateService.update).toHaveBeenCalledWith(property, true);
});

it('should update the property value after a changed', async () => {
component.property.value = true;

component.changed(<MatCheckboxChange> { checked: false });
component.changed({ checked: false } as MatCheckboxChange);

fixture.detectChanges();
await fixture.whenStable();
Expand Down
Expand Up @@ -40,7 +40,7 @@ export class CardViewBoolItemComponent extends BaseCardView<CardViewBoolItemMode
}

changed(change: MatCheckboxChange) {
this.cardViewUpdateService.update(<CardViewBoolItemModel> { ...this.property }, change.checked );
this.cardViewUpdateService.update({ ...this.property } as CardViewBoolItemModel, change.checked );
this.property.value = change.checked;
}
}
Expand Up @@ -86,7 +86,7 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
this.property.locale = locale;
});

(<MomentDateAdapter> this.dateAdapter).overrideDisplayFormat = 'MMM DD';
(this.dateAdapter as MomentDateAdapter).overrideDisplayFormat = 'MMM DD';

if (this.property.value) {
this.valueDate = moment(this.property.value, this.dateFormat);
Expand Down Expand Up @@ -129,7 +129,7 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode

onDateClear() {
this.valueDate = null;
this.cardViewUpdateService.update(<CardViewDateItemModel> { ...this.property }, null);
this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, null);
this.property.value = null;
this.property.default = null;
}
Expand All @@ -155,6 +155,6 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
}

update() {
this.cardViewUpdateService.update(<CardViewDateItemModel> { ...this.property }, this.property.value);
this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, this.property.value);
}
}
Expand Up @@ -59,7 +59,7 @@ describe('CardViewItemDispatcherComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(CardViewItemDispatcherComponent);
component = fixture.componentInstance;
component.property = <CardViewItem> {
component.property = {
type: 'shiny-custom-element',
label: 'Shiny custom element',
value: null,
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('CardViewItemDispatcherComponent', () => {
it('should update the subcomponent\'s input parameters', () => {
const expectedEditable = false;
const expectedDisplayEmpty = true;
const expectedProperty = <CardViewItem> {};
const expectedProperty = {};
const expectedCustomInput = 1;
const expectedDisplayNoneOption = false;
const expectedDisplayClearAction = false;
Expand Down
Expand Up @@ -69,7 +69,7 @@ export class CardViewKeyValuePairsItemComponent extends BaseCardView<CardViewKey
const validValues = this.values.filter((i) => i.name.length && i.value.length);

if (remove || validValues.length) {
this.cardViewUpdateService.update(<CardViewKeyValuePairsItemModel> { ...this.property }, validValues);
this.cardViewUpdateService.update({ ...this.property } as CardViewKeyValuePairsItemModel, validValues);
this.property.value = validValues;
}
}
Expand Down
Expand Up @@ -93,7 +93,7 @@ export class CardViewSelectItemComponent extends BaseCardView<CardViewSelectItem

onChange(event: MatSelectChange): void {
const selectedOption = event.value !== undefined ? event.value : null;
this.cardViewUpdateService.update(<CardViewSelectItemModel<string>> { ...this.property }, selectedOption);
this.cardViewUpdateService.update({ ...this.property } as CardViewSelectItemModel<string>, selectedOption);
this.property.value = selectedOption;
}

Expand Down
Expand Up @@ -44,9 +44,9 @@ export class TestComponent {
showInputFilter = true;
multiple = false;
standardOptions = [
{ 'id': '1', 'name': 'one' },
{ 'id': '2', 'name': 'two' },
{ 'id': '3', 'name': 'three' }
{ id: '1', name: 'one' },
{ id: '2', name: 'two' },
{ id: '3', name: 'three' }
];
options = this.standardOptions;

Expand Down Expand Up @@ -136,7 +136,7 @@ describe('SelectFilterInputComponent', () => {
component.onModelChange('some-search-term');
expect(component.term).toBe('some-search-term');

component.selectFilterInput.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {'keyCode': ESCAPE} as any));
component.selectFilterInput.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {keyCode: ESCAPE} as any));
fixture.detectChanges();
expect(component.term).toBe('');
});
Expand All @@ -152,10 +152,10 @@ describe('SelectFilterInputComponent', () => {
afterEach(() => testFixture.destroy());

it('should preserve the values for multiple search', async () => {
const userSelection = [{ 'id': '3', 'name': 'three' }];
const userSelection = [{ id: '3', name: 'three' }];
const preSelected = [
{ 'id': '1', 'name': 'one' },
{ 'id': '2', 'name': 'two' }
{ id: '1', name: 'one' },
{ id: '2', name: 'two' }
];
testComponent.field.value = preSelected;
testComponent.multiple = true;
Expand Down
Expand Up @@ -25,7 +25,7 @@ import { takeUntil } from 'rxjs/operators';
selector: 'adf-select-filter-input',
templateUrl: './select-filter-input.component.html',
styleUrls: ['./select-filter-input.component.scss'],
host: { 'class': 'adf-select-filter-input' },
host: { class: 'adf-select-filter-input' },
encapsulation: ViewEncapsulation.None
})
export class SelectFilterInputComponent implements OnInit, OnDestroy {
Expand Down Expand Up @@ -79,6 +79,7 @@ export class SelectFilterInputComponent implements OnInit, OnDestroy {

this.previousSelected = values;
if (restoreSelection) {
// eslint-disable-next-line no-underscore-dangle
this.matSelect._onChange(values);
}
});
Expand Down

0 comments on commit bca5a78

Please sign in to comment.