Commit 4e9a999d authored by akarpov's avatar akarpov
Browse files

NAS-112433: Enable no-restricted-globals linter rule

parent 98ed8d1d
Showing with 26 additions and 22 deletions
+26 -22
......@@ -108,7 +108,7 @@ module.exports = {
"no-nested-ternary": "off",
"implicit-arrow-linebreak": "off",
"@typescript-eslint/no-shadow": "off",
"no-restricted-globals": "off",
// "no-restricted-globals": "off",
"no-case-declarations": "off",
"no-multi-str": "off",
"max-classes-per-file": "off",
......
v15.14.0
......@@ -49,6 +49,7 @@ export class Thread extends IxAbstractObject {
readonly main = (): void => {
// Some example code to show how messages can be exchanged with main thread
// eslint-disable-next-line no-restricted-globals
const context: Worker = self as any; // Needed for TypeScript not to complain. DO NOT REMOVE!
context.postMessage('ThreadInitialized'); // This inits the worker. DO NOT REMOVE!
......
......@@ -15,6 +15,7 @@ export class ChartDataUtilsService {
constructor(protected core: CoreService) {
// Operations are what will run on the thread
const operations = (): void => {
// eslint-disable-next-line no-restricted-globals
const context: Worker = self as any; // Required so Typescript doesn't complain
const callback = (data: any): void => {
......
......@@ -388,7 +388,7 @@ export class UserFormComponent implements FormConfiguration {
/* list groups */
this.ws.call('group.query').pipe(untilDestroyed(this)).subscribe((groups) => {
this.loader.callDone.emit(status);
this.loader.callDone.emit(window.status);
this.group = this.fieldSets.config('group') as FormSelectConfig;
this.groups = this.fieldSets.config('groups') as FormSelectConfig;
for (let i = 0; i < groups.length; i++) {
......
......@@ -70,7 +70,7 @@ export class FormInputComponent implements Field {
this.group.controls[this.config.name].value,
this.config.inputUnit,
);
if (isNaN(phrasedValue as number)) {
if (Number.isNaN(phrasedValue as number)) {
this.group.controls[this.config.name].setErrors({
manualValidateError: true,
manualValidateErrorMsg: globalHelptext.invalidInputValueWithUnit,
......
......@@ -155,7 +155,7 @@ function tableUtilsEmit(evt: any): void {
postMessage(evt);
}
addEventListener('message', ({ data }) => {
addEventListener('message', ({ data }) => { // eslint-disable-line no-restricted-globals
const evt = data;
let output;
......
......@@ -116,7 +116,7 @@ export class EntityTreeTableComponent implements OnInit, AfterViewInit {
}
resolve(path: string, obj: any): string {
return path.split('.').reduce((prev, curr) => (prev ? prev[curr] : null), obj || self);
return path.split('.').reduce((prev, curr) => (prev ? prev[curr] : null), obj || self); // eslint-disable-line no-restricted-globals
}
ngAfterViewInit(): void {
......
......@@ -253,7 +253,7 @@ export class TableComponent implements OnInit, AfterViewInit, AfterViewChecked {
} else {
this.tableService.delete(this, row);
}
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
}
// TODO: Enum
......
......@@ -154,7 +154,7 @@ export class BackupCredentialsComponent implements OnInit {
const blob = new Blob([key as any], { type: 'text/plain' });
this.storage.downloadBlob(blob, filename);
}
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
}];
}
......
......@@ -291,7 +291,7 @@ export class CertificatesDashComponent implements OnInit {
new EntityUtils().handleWSError(this, err, this.dialogService);
},
);
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
},
];
......@@ -333,7 +333,7 @@ export class CertificatesDashComponent implements OnInit {
matTooltip: T('Create ACME Certificate'),
onClick: (rowinner: Certificate) => {
this.modalService.openInSlideIn(CertificateAcmeAddComponent, rowinner.id);
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
};
......@@ -350,7 +350,7 @@ export class CertificatesDashComponent implements OnInit {
onClick: (rowinner: CertificateAuthority) => {
this.dialogService.dialogForm(this.signCSRFormConf);
this.caId = rowinner.id;
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
};
......
......@@ -152,7 +152,7 @@ export class WidgetCpuComponent extends WidgetComponent implements AfterViewInit
// Filter out stats per thread
const keys = Object.keys(cpuData);
const threads = keys.filter((n) => !isNaN(parseFloat(n)));
const threads = keys.filter((n) => !Number.isNaN(parseFloat(n)));
for (let i = 0; i < this.threadCount; i++) {
usageColumn.push(parseInt(cpuData[i].usage.toFixed(1)));
......
......@@ -259,7 +259,7 @@ export class WidgetPoolComponent extends WidgetComponent implements OnInit, Afte
}
let usedValue;
if (isNaN(this.volumeData.used)) {
if (isNaN(this.volumeData.used)) { // eslint-disable-line no-restricted-globals
usedValue = this.volumeData.used;
} else {
usedValue = filesize(this.volumeData.used, { exponent: 3 });
......@@ -271,7 +271,7 @@ export class WidgetPoolComponent extends WidgetComponent implements OnInit, Afte
return 0;
}
if (!isNaN(this.volumeData.avail)) {
if (!isNaN(this.volumeData.avail)) { // eslint-disable-line no-restricted-globals
this.voldataavail = true;
}
......
......@@ -255,6 +255,7 @@ export class WidgetStorageComponent extends WidgetComponent implements AfterView
getFreeSpace(pool: Pool): string {
const volume = this.volumeData[pool.name];
if (volume && volume.used_pct) {
// eslint-disable-next-line no-restricted-globals
if (isNaN(volume.used) ? volume.used : filesize(volume.used, { exponent: 3 }) !== 'Locked') {
return this.getSizeString(volume.avail);
}
......
......@@ -1295,7 +1295,7 @@ export class ReplicationFormComponent implements FormConfiguration {
const filteredValue = value ? this.storageService.convertHumanStringToNum(value) : undefined;
speedLimitField['hasErrors'] = false;
speedLimitField['errors'] = '';
if (filteredValue !== undefined && isNaN(filteredValue)) {
if (filteredValue !== undefined && Number.isNaN(filteredValue)) {
speedLimitField['hasErrors'] = true;
speedLimitField['errors'] = helptext.speed_limit_errors;
}
......
......@@ -622,7 +622,7 @@ export class NetworkComponent extends ViewControllerComponent implements OnInit,
'ipmi.identify',
'seconds',
);
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
}, {
icon: 'launch',
......@@ -630,7 +630,7 @@ export class NetworkComponent extends ViewControllerComponent implements OnInit,
matTooltip: T('Manage'),
onClick: (row: IpmiRow) => {
window.open(`http://${row.ipaddress}`);
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
}];
}
......@@ -701,7 +701,7 @@ export class NetworkComponent extends ViewControllerComponent implements OnInit,
);
},
);
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
},
{
......@@ -740,7 +740,7 @@ export class NetworkComponent extends ViewControllerComponent implements OnInit,
);
},
);
event.stopPropagation();
event.stopPropagation(); // eslint-disable-line no-restricted-globals
},
}];
}
......
......@@ -331,7 +331,7 @@ function emit(evt: any): void {
postMessage(evt);
}
addEventListener('message', ({ data }) => {
addEventListener('message', ({ data }) => { // eslint-disable-line no-restricted-globals
const evt = data;
let output;
......
......@@ -459,7 +459,7 @@ export class ServiceFTPComponent implements FormConfiguration, OnInit {
const filteredValue = value ? this.storageService.convertHumanStringToNum(value, false, 'kmgtp') : undefined;
formField['hasErrors'] = false;
formField['errors'] = '';
if (filteredValue !== undefined && isNaN(filteredValue)) {
if (filteredValue !== undefined && Number.isNaN(filteredValue)) {
formField['hasErrors'] = true;
formField['errors'] = helptext.bandwidth_err;
}
......
......@@ -134,7 +134,7 @@ export class ServiceS3Component implements FormConfiguration {
})
.pipe(untilDestroyed(this))
.subscribe(() => {
if (!confirm) {
if (!window.confirm) {
this.storage_path.setValue(this.initial_path);
} else {
this.warned = true;
......
......@@ -127,7 +127,7 @@ export class ExtentFormComponent implements FormConfiguration {
(control: FormControl): ValidationErrors => {
const config = this.fieldConfig.find((c) => c.name === 'filesize');
const size = this.storageService.convertHumanStringToNum(control.value, true);
const errors = control.value && isNaN(size)
const errors = control.value && Number.isNaN(size)
? { invalid_byte_string: true }
: null;
if (errors) {
......
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