Unverified Commit 9e5ed81c authored by Evgeny Stepanovych's avatar Evgeny Stepanovych Committed by GitHub
Browse files

NAS-119035 / 22.12 / enable no-shadow linter rule (#7334)

parent 477d454d
base NAS-010101 NAS-110800 NAS-119131 NAS-119140 NAS-119180-22.12.1 NAS-119431 NAS-119556-23.10 NAS-119615-22.12.1 NAS-119668 NAS-119695 NAS-119749-bluefin NAS-119750-22.12.1 NAS-119806 NAS-119812 NAS-119886-22.12.1 NAS-119996 NAS-119996-bluefin NAS-120045 NAS-120057 NAS-120173-22.12.1 NAS-120181-22.12.1 NAS-120264-22.12.1 NAS-120274 NAS-120296-22.12.1 NAS-120326-22.12.1 NAS-120490_ NAS-120503 NAS-121006-22.12.2 NAS-121124 NAS-121128-22.12.2 NAS-121128-release-22.12.2 NAS-121136 NAS-121177 NAS-121218-22.12.3 NAS-121300 NAS-121316 NAS-121541 NAS-121542 NAS-121686 NAS-121721-22.12.3 NAS-121778 NAS-121827 NAS-121884-22.12.3 NAS-122267-22.12.4 NAS-122372 NAS-122601 NAS-122686 NAS-122706 NAS-122721 NAS-122751-23.10-BETA.1 NAS-122759 NAS-122781 NAS-122794-23.10 NAS-122855 NAS-122870-bluefin NAS-122969 NAS-122993-22.12.4 NAS-123055-22.12.4 NAS-123278 NAS-123295 NAS-123437 NAS-123478-22.12.4 NAS-123484 NAS-123492 NAS-123526-22.12.4 NAS-123651 NAS-123651-23.10-BETA.1 NAS-123666 NAS-123723 NAS-123723-cobia NAS-123762 NAS-123762-23.10 NAS-123778-23.10 NAS-123778-23.10-RC.1 NAS-123778-RC.1 NAS-123801 NAS-123810-23.10 NAS-123813-22.12.4 NAS-123836 NAS-123836-23.10-BETA.1 NAS-123836-24.04 NAS-123861 NAS-123911-23.10-BETA.1 NAS-123928-23.10 NAS-123931-22.12.4 NAS-123945 NAS-124044 NAS-124077 NAS-124131-23.10 NAS-124137 NAS-124183 NAS-124231 NAS-124232 NAS-124237-23.10 NAS-124325-23.10.0 NAS-124335 NAS-124354 NAS-124430 NAS-124454 NAS-124481-23.10.0 NAS-124481-23.10.1 NAS-124555-23.10.0 NAS-124555-23.10.1 NAS-124666 NAS-124707-23.10.0 NAS-124707-23.10.1 NAS-124716 NAS-124846-23.10.0 NAS-124846-23.10.1 NAS-124892 NAS-124895-23.10.1 NAS-124908 NAS-124951 NAS-124964 NAS-124999 NAS-125092 NAS-125213-23.10.1 NAS-125307 NAS-125532 NAS-125568 NAS-125607-validator NAS-125616-23.10.2 NAS-125654 NAS-125703-23.10.2 NAS-125728 NAS-125931 NAS-126699 NAS-126774-24.04-RC.1 NAS-126774-dragonfish NAS-126795 NAS-126795-test NAS-126795-test2 NAS-127001 NAS-127002-24.04-RC.1 NAS-127022 NAS-127041-24.04-BETA.1 NAS-127049-24.04-RC.1 NAS-127297-24.04-RC.1 NAS-127297-24.10 NAS-127369 NAS-127551 NAS-127551-alt NAS-127589-24.04.0 NAS-127593 NAS-127615-24.04.0 NAS-127660 NAS-127794 NAS-127829-24.10 NAS-127854-24.04.0 NAS-128030 NAS-128045 NAS-128071 NAS-128173 NAS-128209 NAS-128287 NAS-128289 TE-1553-dragonfish TE-1628 auto-129 developer/lyy llll master metrics-enable patch-1 patch-235 rel-v0.0.1 release/22.12 release/22.12.1 release/22.12.2 release/22.12.3 release/22.12.4 release/23.10-BETA.1 release/23.10-RC.1 release/23.10.0 release/23.10.1 release/23.10.1.1 release/23.10.1.2 release/23.10.1.3 release/23.10.2 release/24.04-BETA.1 release/24.04-RC.1 release/24.04.0 renediepenbroek/master revert-7745-NAS-120274 stable/bluefin stable/cobia stable/dragonfish test-xxxyyy testing-refine-branchout-process testing-refine-branchout-process2 v0.0.2 TS-24.04-RC.1 TS-24.04-BETA.1 TS-23.10.2 TS-23.10.1.3 TS-23.10.1.2 TS-23.10.1.1 TS-23.10.1 TS-23.10.0.1 TS-23.10.0 TS-23.10-RC.1 TS-23.10-BETA.1 TS-22.12.4.2 TS-22.12.4.1 TS-22.12.4 TS-22.12.3.3 TS-22.12.3.2 TS-22.12.3.1 TS-22.12.3 TS-22.12.2 TS-22.12.1 TS-22.12.0 TS-12.12.3 DN110M-CS-v2.0
No related merge requests found
Showing with 61 additions and 63 deletions
+61 -63
......@@ -131,7 +131,7 @@ module.exports = {
],
"@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true, allowAny: true }],
// TODO: Aibnb rules that are disabled for now as they cannot be fixed automatically
// TODO: Airbnb rules that are disabled for now as they cannot be fixed automatically
"no-underscore-dangle": "off",
"consistent-return": "off",
"no-plusplus": "off",
......@@ -153,7 +153,6 @@ module.exports = {
"no-param-reassign": "off",
"@typescript-eslint/no-loop-func": "off",
"no-await-in-loop": "off",
"@typescript-eslint/no-shadow": "off",
"no-multi-str": "off",
"no-mixed-operators": ["error", {
groups: [
......
......@@ -2,6 +2,7 @@ import { ApiMethod } from 'app/interfaces/api-directory.interface';
import { Job } from 'app/interfaces/job.interface';
export enum MockWebsocketResponseType {
// eslint-disable-next-line @typescript-eslint/no-shadow
Job = 'job',
Call = 'call',
}
......@@ -15,5 +16,5 @@ export interface MockWebsocketCallResponse {
export interface MockWebsocketJobResponse {
type: MockWebsocketResponseType.Job;
method: ApiMethod;
response: Job<unknown>;
response: Job;
}
......@@ -4,8 +4,8 @@ import { map } from 'rxjs/operators';
import { Choices } from 'app/interfaces/choices.interface';
import { MapOption, Option } from 'app/interfaces/option.interface';
export function mapToOptions(map: Map<string, string>, translate: TranslateService): Option[] {
return Array.from(map.entries()).map(([value, label]) => ({ label: translate.instant(label), value }));
export function mapToOptions(optionMap: Map<string, string>, translate: TranslateService): Option[] {
return Array.from(optionMap.entries()).map(([value, label]) => ({ label: translate.instant(label), value }));
}
/**
......
......@@ -65,7 +65,6 @@ export interface Dataset {
// Absent if extra.retrieve_children is false
children?: Dataset[];
// TODO: Need to confirm that these properties are valid backend properties
refquota_critical?: ZfsProperty<number>;
refquota_warning?: ZfsProperty<number>;
quota_critical?: ZfsProperty<number>;
......
......@@ -35,7 +35,7 @@ export interface SystemLicense {
features: LicenseFeature[];
legacy_contract_hardware: unknown;
legacy_contract_software: unknown;
model: string; // TODO: Enum?
model: string;
system_serial: string;
system_serial_ha: string;
}
......@@ -143,8 +143,8 @@ describe('AlertsPanelComponent', () => {
it('adds an alert when websocket alert.list subscription sends an "add" event', () => {
spectator.inject(Store).dispatch(adminUiInitialized());
const mockWebsocket = spectator.inject(MockWebsocketService);
mockWebsocket.emitSubscribeEvent({
const websocketMock = spectator.inject(MockWebsocketService);
websocketMock.emitSubscribeEvent({
msg: ApiEventMessage.Added,
collection: 'alert.list',
fields: {
......@@ -162,8 +162,8 @@ describe('AlertsPanelComponent', () => {
it('updates an alert when websocket alert.list subscription sends a "change" event', () => {
spectator.inject(Store).dispatch(adminUiInitialized());
const mockWebsocket = spectator.inject(MockWebsocketService);
mockWebsocket.emitSubscribeEvent({
const websocketMock = spectator.inject(MockWebsocketService);
websocketMock.emitSubscribeEvent({
msg: ApiEventMessage.Changed,
collection: 'alert.list',
fields: {
......
......@@ -253,23 +253,23 @@ export class EntityFormComponent implements OnInit, OnDestroy, OnChanges, AfterV
} else if (this.conf.queryCall) {
if (this.pk) {
let pk = this.pk;
let filter = [];
let filterParam = [];
if (this.conf.pk) {
filter.push(this.conf.pk);
filterParam.push(this.conf.pk);
pk = this.conf.pk;
}
if (this.conf.queryCallOption) {
filter.push(this.conf.queryCallOption);
filterParam.push(this.conf.queryCallOption);
}
if (this.conf.customFilter) {
filter = this.conf.customFilter;
filterParam = this.conf.customFilter;
}
if (this.conf.queryKey) {
filter = [[[this.conf.queryKey, '=', parseInt(pk as string, 10) || pk]]]; // parse pk to int if possible (returns NaN otherwise)
filterParam = [[[this.conf.queryKey, '=', parseInt(pk as string, 10) || pk]]]; // parse pk to int if possible (returns NaN otherwise)
}
this.getFunction = this.ws.call(
this.conf.queryCall,
filter as ApiParams<keyof ApiDirectory>,
filterParam as ApiParams<keyof ApiDirectory>,
) as Observable<Record<string, unknown>>;
} else {
this.getFunction = this.ws.call(this.conf.queryCall, []) as Observable<Record<string, unknown>>;
......
......@@ -41,10 +41,10 @@ export class FieldRelationService {
} else {
const subControlKeys = Object.keys(controlGroup.controls).filter((key) => key.startsWith(`${rel.name}_`));
subControlKeys.forEach((key) => {
const control = controlGroup.get(key) as UntypedFormControl;
if (control
&& !controls.some((controlElement) => controlElement === control)) {
controls.push(control);
const subControl = controlGroup.get(key) as UntypedFormControl;
if (subControl
&& !controls.some((controlElement) => controlElement === subControl)) {
controls.push(subControl);
}
});
}
......
......@@ -1069,12 +1069,12 @@ export class EntityTableComponent<Row extends SomeRow = SomeRow> implements OnIn
cols: this.conf.columns,
} as unknown as TableDisplayedColumns;
this.store$.pipe(select(selectPreferencesState), take(1), untilDestroyed(this)).subscribe((state) => {
if (!state.areLoaded) {
this.store$.pipe(select(selectPreferencesState), take(1), untilDestroyed(this)).subscribe((preferencesState) => {
if (!preferencesState.areLoaded) {
return;
}
const existingPreferredColumns = state.preferences.tableDisplayedColumns || [];
const existingPreferredColumns = preferencesState.preferences.tableDisplayedColumns || [];
const preferredColumns = existingPreferredColumns.filter((column) => {
return column.title !== this.title;
});
......@@ -1124,9 +1124,9 @@ export class EntityTableComponent<Row extends SomeRow = SomeRow> implements OnIn
// Bring warnings to user's attention even if state is finished or successful.
if (row.warnings && row.warnings.length > 0) return 'fn-theme-orange';
const state: JobState = row.state;
const jobState = row.state;
switch (state) {
switch (jobState) {
case JobState.Pending:
case JobState.Running:
case JobState.Aborted:
......
......@@ -65,7 +65,7 @@
>
<div>
<a [routerLink]="tableConf.detailsHref.split('/')">
{{ 'View Details' | translate }}
{{ 'View All' | translate }}
</a>
</div>
</div>
......
......@@ -39,7 +39,7 @@ describe('IxDropGridDirective', () => {
],
});
function setupMocks(spectator: SpectatorDirective<IxDropGridDirective>): void {
function setupMocks(): void {
resolveAndCreateOriginal = ReflectiveInjector.resolveAndCreate;
ReflectiveInjector.resolveAndCreate = jest.fn().mockReturnValue(fakeInjector);
......@@ -62,7 +62,7 @@ describe('IxDropGridDirective', () => {
describe('ngOnInit()', () => {
beforeEach(() => {
spectator = createDirective(null, { detectChanges: false });
setupMocks(spectator);
setupMocks();
});
afterEach(() => {
......@@ -83,7 +83,7 @@ describe('IxDropGridDirective', () => {
describe('registerPlaceholder()', () => {
beforeEach(() => {
spectator = createDirective(null, { detectChanges: false });
setupMocks(spectator);
setupMocks();
});
afterEach(() => {
restoreMocks();
......@@ -98,7 +98,7 @@ describe('IxDropGridDirective', () => {
describe('registerItem()', () => {
beforeEach(() => {
spectator = createDirective(null, { detectChanges: false });
setupMocks(spectator);
setupMocks();
});
afterEach(() => {
restoreMocks();
......@@ -157,7 +157,7 @@ describe('IxDropGridDirective', () => {
beforeEach(() => {
spectator = createDirective(null, { detectChanges: false });
setupMocks(spectator);
setupMocks();
const fakeSourceParentElement = {
removeChild: jest.fn(),
......@@ -343,7 +343,7 @@ describe('IxDropGridDirective', () => {
beforeEach(() => {
spectator = createDirective(null, { detectChanges: false });
setupMocks(spectator);
setupMocks();
fakeParentElement = {
appendChild: jest.fn(),
......
......@@ -40,8 +40,8 @@ describe('ChangePasswordDialogComponent', () => {
});
it('checks current user password and shows an error if it is not correct', async () => {
const mockWebsocket = spectator.inject(MockWebsocketService);
mockWebsocket.mockCallOnce('auth.check_user', false);
const websocketMock = spectator.inject(MockWebsocketService);
websocketMock.mockCallOnce('auth.check_user', false);
const form = await loader.getHarness(IxFormHarness);
await form.fillForm({
......
......@@ -65,8 +65,8 @@ describe('DirectoryServicesIndicatorComponent', () => {
const icon = spectator.query('button');
expect(icon).toExist();
const mockWebsocket = spectator.inject(MockWebsocketService);
mockWebsocket.subscribe.mockImplementation(() => of({
const websocketMock = spectator.inject(MockWebsocketService);
websocketMock.subscribe.mockImplementation(() => of({
fields: {
activedirectory: DirectoryServiceState.Disabled,
ldap: DirectoryServiceState.Disabled,
......
......@@ -71,8 +71,8 @@ describe('DeleteUserDialogComponent', () => {
});
it('shows Delete primary group checkbox if this is the last user in the group', async () => {
const mockWebsocket = spectator.inject(MockWebsocketService);
mockWebsocket.mockCall('group.query', [
const websocketMock = spectator.inject(MockWebsocketService);
websocketMock.mockCall('group.query', [
{
users: [1],
},
......
......@@ -296,18 +296,18 @@ export class ChartReleasesComponent implements AfterViewInit, OnInit, OnDestroy
} as ChartUpgradeDialogConfig,
});
dialogRef.afterClosed().pipe(filter(Boolean), untilDestroyed(this)).subscribe((version) => {
const dialogRef = this.mdDialog.open(EntityJobComponent, {
const jobDialogRef = this.mdDialog.open(EntityJobComponent, {
data: {
title: helptext.charts.upgrade_dialog.job,
},
});
dialogRef.componentInstance.setCall('chart.release.upgrade', [name, { item_version: version }]);
dialogRef.componentInstance.submit();
dialogRef.componentInstance.success.pipe(untilDestroyed(this)).subscribe(() => {
jobDialogRef.componentInstance.setCall('chart.release.upgrade', [name, { item_version: version }]);
jobDialogRef.componentInstance.submit();
jobDialogRef.componentInstance.success.pipe(untilDestroyed(this)).subscribe(() => {
this.dialogService.closeAllDialogs();
this.refreshChartReleases();
});
dialogRef.componentInstance.failure.pipe(untilDestroyed(this)).subscribe((error) => {
jobDialogRef.componentInstance.failure.pipe(untilDestroyed(this)).subscribe((error) => {
this.dialogService.closeAllDialogs();
new EntityUtils().handleWsError(this, error, this.dialogService);
});
......
......@@ -50,13 +50,13 @@ export class DockerImageDeleteDialogComponent {
onSubmit(): void {
const { force } = this.form.value;
const params = this.images.map((image) => [image.id, { force }]);
const deleteParams = this.images.map((image) => [image.id, { force }]);
this.images.forEach((image) => {
this.bulkItems.set(image.id, { state: BulkListItemState.Running, item: image });
});
this.ws.job('core.bulk', ['container.image.delete', params]).pipe(
this.ws.job('core.bulk', ['container.image.delete', deleteParams]).pipe(
filter((job: Job<CoreBulkResponse<void>[], DeleteContainerImageParams[]>) => !!job.result),
untilDestroyed(this),
).subscribe((response) => {
......
......@@ -117,10 +117,10 @@ export class ManageCatalogsComponent implements EntityTableConfig<Catalog>, OnIn
this.entityList = entityList;
}
getActions(row: Catalog): EntityTableAction[] {
getActions(catalog: Catalog): EntityTableAction[] {
return [
{
id: row.id,
id: catalog.id,
icon: 'edit',
label: helptext.manageCatalogs.menu.edit,
name: 'edit',
......@@ -129,7 +129,7 @@ export class ManageCatalogsComponent implements EntityTableConfig<Catalog>, OnIn
},
},
{
id: row.id,
id: catalog.id,
icon: 'refresh',
label: helptext.manageCatalogs.menu.refresh,
name: 'refresh',
......@@ -138,17 +138,17 @@ export class ManageCatalogsComponent implements EntityTableConfig<Catalog>, OnIn
},
},
{
id: row.id,
id: catalog.id,
icon: 'delete',
label: helptext.manageCatalogs.menu.delete,
name: 'delete',
disabled: row.builtin,
disabled: catalog.builtin,
onClick: (row: Catalog) => {
this.entityList.doDelete(row);
},
},
{
id: row.id,
id: catalog.id,
icon: 'summary',
label: helptext.manageCatalogs.menu.summary,
name: 'summary',
......
......@@ -160,8 +160,8 @@ describe('CloudCredentialsFormComponent', () => {
});
it('shows an error when verification fails', async () => {
const mockWebsocket = spectator.inject(MockWebsocketService);
mockWebsocket.mockCall('cloudsync.credentials.verify', {
const websocketMock = spectator.inject(MockWebsocketService);
websocketMock.mockCall('cloudsync.credentials.verify', {
valid: false,
excerpt: 'Missing some important field',
error: 'Some error',
......
......@@ -84,14 +84,14 @@ export class OneDriveProviderFormComponent extends BaseProviderFormComponent imp
private setupDriveSelect(): void {
this.form.controls.drives.valueChanges.pipe(untilDestroyed(this)).subscribe((driveId) => {
const drive = this.drives.find((drive) => drive.drive_id === driveId);
if (!drive) {
const selectedDrive = this.drives.find((drive) => drive.drive_id === driveId);
if (!selectedDrive) {
return;
}
this.form.patchValue({
drive_type: drive.drive_type,
drive_id: drive.drive_id,
drive_type: selectedDrive.drive_type,
drive_id: selectedDrive.drive_id,
});
});
}
......
......@@ -630,9 +630,9 @@ export class CertificateAuthorityAddComponent implements WizardConfiguration {
getSummaryValueLabel(fieldConfig: FieldConfig, value: unknown): unknown {
if (fieldConfig.type === 'select') {
const option = fieldConfig.options.find((option) => option.value === value);
if (option) {
value = option.label;
const selectedOption = fieldConfig.options.find((option) => option.value === value);
if (selectedOption) {
value = selectedOption.label;
}
}
......@@ -642,11 +642,10 @@ export class CertificateAuthorityAddComponent implements WizardConfiguration {
addToSummary(fieldName: string): void {
const fieldConfig = this.getTarget(fieldName);
if (!fieldConfig.isHidden) {
const fieldName = fieldConfig.name;
if (fieldConfig.value !== undefined) {
this.summary[fieldConfig.placeholder] = this.getSummaryValueLabel(fieldConfig, fieldConfig.value);
}
this.getField(fieldName).valueChanges.pipe(untilDestroyed(this)).subscribe((res) => {
this.getField(fieldConfig.name).valueChanges.pipe(untilDestroyed(this)).subscribe((res) => {
this.summary[fieldConfig.placeholder] = this.getSummaryValueLabel(fieldConfig, res);
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment