fix eslint warnigs for core project (#7506)

This commit is contained in:
Denys Vuika
2022-02-17 14:35:33 +00:00
committed by GitHub
parent 5b7f255eec
commit bca5a783ab
246 changed files with 5127 additions and 5065 deletions

View File

@@ -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',

View File

@@ -184,7 +184,7 @@ 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);
});
@@ -192,7 +192,7 @@ describe('CardViewBoolItemComponent', () => {
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();

View File

@@ -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;
}
}

View File

@@ -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);
@@ -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;
}
@@ -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);
}
}

View File

@@ -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,
@@ -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;

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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;
@@ -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('');
});
@@ -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;

View File

@@ -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 {
@@ -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);
}
});

View File

@@ -904,28 +904,28 @@ describe('CardViewTextItemComponent', () => {
});
});
function updateTextField(key, value) {
const updateTextField = (key, value) => {
const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
editInput.nativeElement.value = value;
editInput.nativeElement.dispatchEvent(new Event('input'));
fixture.detectChanges();
}
};
function getTextFieldValue(key): string {
const getTextFieldValue = (key): string => {
const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
expect(textItemInput).not.toBeNull();
return textItemInput.nativeElement.value;
}
};
function getTextField(key): DebugElement {
const getTextField = (key): DebugElement => {
const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
expect(textItemInput).not.toBeNull();
return textItemInput;
}
};
function getTextFieldError(key): string {
const getTextFieldError = (key): string => {
const textItemInputError = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${key}"] li`));
expect(textItemInputError).not.toBeNull();
return textItemInputError.nativeElement.innerText;
}
};
});

View File

@@ -132,7 +132,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
update(): void {
if (this.property.isValid(this.editedValue)) {
this.property.value = this.prepareValueForUpload(this.property, this.editedValue);
this.cardViewUpdateService.update(<CardViewTextItemModel> { ...this.property }, this.property.value);
this.cardViewUpdateService.update({ ...this.property } as CardViewTextItemModel, this.property.value);
this.resetErrorMessages();
} else {
this.errors = this.property.getValidationErrors(this.editedValue);

View File

@@ -145,7 +145,7 @@ describe('CardViewComponent', () => {
});
it('should render the select element with the None option when not set in the properties', async () => {
const options: CardViewSelectItemOption<string>[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}];
const options: CardViewSelectItemOption<string>[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}];
component.properties = [new CardViewSelectItemModel({
label: 'My default label',
value: '1',
@@ -173,7 +173,7 @@ describe('CardViewComponent', () => {
});
it('should render the select element with the None option when set true in the properties', async () => {
const options: CardViewSelectItemOption<string>[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}];
const options: CardViewSelectItemOption<string>[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}];
component.properties = [new CardViewSelectItemModel({
label: 'My default label',
value: '1',
@@ -202,7 +202,7 @@ describe('CardViewComponent', () => {
});
it('should not render the select element with the None option when set false in the properties', async () => {
const options: CardViewSelectItemOption<string>[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}];
const options: CardViewSelectItemOption<string>[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}];
component.properties = [new CardViewSelectItemModel({
label: 'My default label',
value: '1',