Fix ESLint errors in cvat-core/src/server-proxy.ts (#5189)

* Fix incorrect requires of the ./config module

It's an ES6 module, so we need to use the `default` field, or we'll get the
module itself instead.

* Fix ESLint errors in cvat-core/src/server-proxy.ts

Specifically:

* `padded-blocks`
* `@typescript-eslint/no-var-requires`
* `@typescript-eslint/return-await`
main
Roman Donchenko 3 years ago committed by GitHub
parent fe10995b5f
commit 80c72340f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "7.0.1",
"version": "7.0.2",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "src/api.ts",
"scripts": {

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT
const config = require('./config');
const config = require('./config').default;
(() => {
const PluginRegistry = require('./plugins').default;

@ -34,7 +34,7 @@ function build() {
const User = require('./user').default;
const pjson = require('../package.json');
const config = require('./config');
const config = require('./config').default;
/**
* API entrypoint

@ -3,9 +3,16 @@
//
// SPDX-License-Identifier: MIT
import { isEmail } from './common';
import { StorageLocation, WebhookSourceType } from './enums';
import FormData from 'form-data';
import store from 'store';
import Axios from 'axios';
import * as tus from 'tus-js-client';
import { Storage } from './storage';
import { StorageLocation, WebhookSourceType } from './enums';
import { isEmail } from './common';
import config from './config';
import DownloadWorker from './download.worker';
import { ServerError } from './exceptions';
type Params = {
org: number | string,
@ -17,14 +24,6 @@ type Params = {
action?: string,
};
const FormData = require('form-data');
const store = require('store');
const Axios = require('axios');
const tus = require('tus-js-client');
const config = require('./config');
const DownloadWorker = require('./download.worker');
const { ServerError } = require('./exceptions');
function enableOrganization() {
return { org: config.organizationID || '' };
}
@ -302,7 +301,6 @@ class ServerProxy {
return [];
} catch (errorData) {
throw generateError(errorData);
}
}
@ -426,6 +424,21 @@ class ServerProxy {
}
}
async function getSelf() {
const { backendAPI } = config;
let response = null;
try {
response = await Axios.get(`${backendAPI}/users/self`, {
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData);
}
return response.data;
}
async function authorized() {
try {
await getSelf();
@ -742,7 +755,7 @@ class ServerProxy {
}
}
try {
return wait();
return await wait();
} catch (errorData) {
throw generateError(errorData);
}
@ -1272,21 +1285,6 @@ class ServerProxy {
return response.data.results;
}
async function getSelf() {
const { backendAPI } = config;
let response = null;
try {
response = await Axios.get(`${backendAPI}/users/self`, {
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData);
}
return response.data;
}
async function getPreview(tid, jid) {
const { backendAPI } = config;
@ -1517,7 +1515,7 @@ class ServerProxy {
}
try {
return wait();
return await wait();
} catch (errorData) {
throw generateError(errorData);
}

Loading…
Cancel
Save