Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#194 Follow up and housekeeping #136

Merged
merged 2 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @type {import('eslint').Linter.Config} */
const year = new Date().getFullYear();
module.exports = {
root: true,
extends: ['./configs/base.eslintrc.json', './configs/warnings.eslintrc.json', './configs/errors.eslintrc.json'],
Expand All @@ -14,6 +15,32 @@ module.exports = {
'no-unused-expressions': 0,
'no-invalid-this': 0
}
},
{
files: ['*.ts', '*.tsx'],
rules: {
// eslint-plugin-header
'header/header': [
2,
'block',
[
{
pattern: '[\n\r]+ \\* Copyright \\([cC]\\) \\d{4}(-\\d{4})? .*[\n\r]+',
template: `********************************************************************************
* Copyright (c) ${year} EclipseSource and others..
ndoschek marked this conversation as resolved.
Show resolved Hide resolved
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0, or the MIT License which is
* available at https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: EPL-2.0 OR MIT
********************************************************************************`
}
]
]
}
}
]
};
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ spec:
tty: true
resources:
limits:
memory: "2Gi"
cpu: "1"
memory: "4Gi"
cpu: "2"
requests:
memory: "2Gi"
cpu: "1"
memory: "4Gi"
cpu: "2"
command:
- cat
volumeMounts:
Expand Down
19 changes: 0 additions & 19 deletions configs/errors.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,6 @@
}
],
"@typescript-eslint/semi": ["error", "always"],
// eslint-plugin-header
"header/header": [
2,
"block",
[
"*******************************************************************************",
{
"pattern": " \\* Copyright \\([cC]\\) \\d{4}(-\\d{4})? .+"
},
" *",
" * This program and the accompanying materials are made available under the",
" * terms of the Eclipse Public License v. 2.0 which is available at",
" * https://www.eclipse.org/legal/epl-2.0, or the MIT License which is",
" * available at https://opensource.org/licenses/MIT.",
" *",
" * SPDX-License-Identifier: EPL-2.0 OR MIT",
" ******************************************************************************"
]
],
// eslint-plugin-import
"import/export": "off", // we have multiple exports due to namespaces, enums and classes that share the same name
"import/no-deprecated": "error",
Expand Down
2 changes: 1 addition & 1 deletion packages/modelserver-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"fast-json-patch": "^3.1.0",
"isomorphic-ws": "^4.0.1",
"urijs": "^1.19.11",
"ws": "^7.4.6"
"ws": "8.5.0"
ndoschek marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@types/moxios": "0.4.14",
Expand Down
10 changes: 3 additions & 7 deletions packages/modelserver-client/src/model-server-client-v2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2022 STMicroelectronics and others.
* Copyright (c) 2022-2023 STMicroelectronics and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR MIT
*******************************************************************************/
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import { deepClone } from 'fast-json-patch';
import WebSocket from 'isomorphic-ws';
import URI from 'urijs';
Expand Down Expand Up @@ -344,7 +344,7 @@ export class ModelServerClientV2 implements ModelServerClientApiV2 {
}
return mapper(response.data);
} catch (error) {
if (isAxiosError(error)) {
if (axios.isAxiosError(error)) {
eneufeld marked this conversation as resolved.
Show resolved Hide resolved
const message = error.response?.data ? error.response.data : error.message;
throw new ModelServerError(message, error.code);
} else {
Expand All @@ -354,10 +354,6 @@ export class ModelServerClientV2 implements ModelServerClientApiV2 {
}
}

function isAxiosError(error: any): error is AxiosError {
return error !== undefined && error instanceof Error && 'isAxiosError' in error && error['isAxiosError'];
}

/**
* Helper type for method overloads where on parameter could either be
* a 'format' string or a typeguard to cast the response to a concrete type.
Expand Down
10 changes: 3 additions & 7 deletions packages/modelserver-client/src/model-server-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021-2022 STMicroelectronics and others.
* Copyright (c) 2021-2023 STMicroelectronics and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR MIT
*******************************************************************************/
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import WebSocket from 'isomorphic-ws';
import URI from 'urijs';

Expand Down Expand Up @@ -266,7 +266,7 @@ export class ModelServerClient implements ModelServerClientApiV1 {
}
return mapper(response.data);
} catch (error) {
if (isAxiosError(error)) {
if (axios.isAxiosError(error)) {
const message = error.response?.data ? error.response.data : error.message;
throw new ModelServerError(message, error.code);
} else {
Expand All @@ -276,10 +276,6 @@ export class ModelServerClient implements ModelServerClientApiV1 {
}
}

function isAxiosError(error: any): error is AxiosError {
return error !== undefined && error instanceof Error && 'isAxiosError' in error && error['isAxiosError'];
}

/**
* Helper type for method overloads where on parameter could either be
* a 'format' string or a typeguard to cast the response to a concrete type.
Expand Down
Loading