Skip to content

Commit

Permalink
chore: use absolute paths for imports
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Kurinnyi <[email protected]>
  • Loading branch information
akurinnoy committed Oct 4, 2023
1 parent 443c826 commit 8875bd2
Show file tree
Hide file tree
Showing 578 changed files with 3,449 additions and 2,453 deletions.
12 changes: 11 additions & 1 deletion .deps/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://www.github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #4131 |
Expand Down Expand Up @@ -241,6 +242,7 @@
| [`[email protected]`](https://github.com/stevemao/array-ify.git) | MIT | clearlydefined |
| [`[email protected]`](git://github.com/es-shims/array-includes.git) | MIT | #4577 |
| [`[email protected]`](https://github.com/sindresorhus/array-union.git) | MIT | clearlydefined |
| [`[email protected]`](git+https://github.com/es-shims/Array.prototype.findLastIndex.git) | MIT | #9900 |
| [`[email protected]`](git://github.com/es-shims/Array.prototype.flat.git) | MIT | #4574 |
| [`[email protected]`](git://github.com/es-shims/Array.prototype.flatMap.git) | MIT | #4651 |
| [`[email protected]`](git+https://github.com/es-shims/Array.prototype.toSorted.git) | MIT | #5051 |
Expand Down Expand Up @@ -352,6 +354,7 @@
| [`[email protected]`](https://github.com/sindresorhus/default-browser-id.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/sindresorhus/default-browser.git) | MIT | clearlydefined |
| [`[email protected]`](git://github.com/sindresorhus/node-defaults.git) | MIT | clearlydefined |
| [`[email protected]`](git+https://github.com/ljharb/define-data-property.git) | MIT | #10591 |
| [`[email protected]`](https://github.com/sindresorhus/define-lazy-prop.git) | MIT | clearlydefined |
| [`[email protected]`](git://github.com/ljharb/define-properties.git) | MIT | #7116 |
| [`[email protected]`](https://github.com/sindresorhus/del.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -395,10 +398,15 @@
| [`[email protected]`](https://github.com/lukeed/escalade.git) | MIT | clearlydefined |
| [`[email protected]`](http://github.com/estools/escodegen.git) | BSD-2-Clause | #9306 |
| [`[email protected]`](https://github.com/prettier/eslint-config-prettier.git) | MIT | (clearlydefined)[https://clearlydefined.io/definitions/npm/npmjs/-/eslint-config-prettier/9.0.0] |
| [`[email protected]`](https://github.com/import-js/eslint-plugin-import) | MIT | #9923 |
| [`[email protected]`](git+https://github.com/import-js/eslint-plugin-import.git) | MIT | #8209 |
| [`[email protected]`](https://github.com/import-js/eslint-plugin-import) | MIT | #9927 |
| [`[email protected]`](https://github.com/MelvinVermeer/eslint-plugin-no-relative-import-paths) | ISC | clearlydefined |
| [`[email protected]`](https://github.com/nickdeis/eslint-plugin-notice) | MIT | clearlydefined |
| [`[email protected]`](git+https://github.com/prettier/eslint-plugin-prettier.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/facebook/react.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/jsx-eslint/eslint-plugin-react) | MIT | #9877 |
| [`[email protected]`](https://github.com/lydell/eslint-plugin-simple-import-sort.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/eslint/eslint-scope.git) | BSD-2-Clause | clearlydefined |
| [`[email protected]`](https://github.com/eslint/eslint-visitor-keys.git) | Apache-2.0 | #7729 |
| [`[email protected]`](https://github.com/webpack-contrib/eslint-webpack-plugin.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -678,6 +686,7 @@
| [`[email protected]`](git://github.com/ljharb/object.assign.git) | MIT | #3232 |
| [`[email protected]`](git://github.com/es-shims/Object.entries.git) | MIT | #4671 |
| [`[email protected]`](git://github.com/es-shims/Object.fromEntries.git) | MIT | #4600 |
| [`[email protected]`](git+https://github.com/es-shims/Object.groupBy.git) | MIT | #10360 |
| [`[email protected]`](https://github.com/es-shims/Object.hasOwn.git) | MIT | #4667 |
| [`[email protected]`](git://github.com/es-shims/Object.values.git) | MIT | #4665 |
| [`[email protected]`](https://github.com/sindresorhus/onetime.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -805,6 +814,7 @@
| [`[email protected]`](https://github.com/webpack/schema-utils.git) | MIT | #8986 |
| [`[email protected]`](git+https://github.com/yahoo/serialize-javascript.git) | BSD-3-Clause | clearlydefined |
| [`[email protected]`](git+https://github.com/yargs/set-blocking.git) | ISC | #5899 |
| [`[email protected]`](git+https://github.com/ljharb/set-function-name.git) | MIT | #10590 |
| [`[email protected]`](https://github.com/jonschlinkert/shallow-clone.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/kevva/shebang-command.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/sindresorhus/shebang-regex.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -884,7 +894,7 @@
| [`[email protected]`](https://github.com/JoshuaKGoldberg/ts-api-utils) | MIT | clearlydefined |
| [`[email protected]`](git+https://github.com/kulshekhar/ts-jest.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/TypeStrong/ts-loader.git) | MIT | #5028 |
| [`tsconfig-paths@4.2.0`](https://github.com/dividab/tsconfig-paths) | MIT | #7709 |
| [`tsconfig-paths@3.14.2`](https://github.com/dividab/tsconfig-paths) | MIT | clearlydefined |
| [`[email protected]`](git+https://github.com/theupdateframework/tuf-js.git) | MIT | #7585 |
| [`[email protected]`](git://github.com/gkz/type-check.git) | MIT | clearlydefined |
| [`[email protected]`](git+ssh://[email protected]/chaijs/type-detect.git) | MIT | clearlydefined |
Expand Down
16 changes: 16 additions & 0 deletions packages/dashboard-backend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ module.exports = {
extends: [
'../../.eslintrc.js',
],
plugins: [
'import',
'no-relative-import-paths',
'simple-import-sort',
],
rules: {
'notice/notice': [
'error',
Expand All @@ -28,5 +33,16 @@ module.exports = {
},
},
],

'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",

"no-relative-import-paths/no-relative-import-paths": [
"error",
{ "allowSameFolder": false, 'prefix': '@', 'rootDir': 'src' }
]
},
};
9 changes: 9 additions & 0 deletions packages/dashboard-backend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.tabSize": 2,
"search.exclude": {
"**/lib": true,
"**/coverage": true
},
"typescript.preferences.importModuleSpecifier": "non-relative",
"javascript.preferences.importModuleSpecifier": "non-relative"
}
4 changes: 4 additions & 0 deletions packages/dashboard-backend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module.exports = {
moduleDirectories: [
'node_modules',
],
moduleNameMapper: {
// mapping for absolute imports (see tsconfig.json)
'^@/(.*)$': '<rootDir>/src/$1',
},
collectCoverageFrom: [
...base.collectCoverageFrom,

Expand Down
3 changes: 3 additions & 0 deletions packages/dashboard-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@
"copy-webpack-plugin": "^11.0.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-no-relative-import-paths": "^1.5.2",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-webpack-plugin": "^4.0.1",
"file-loader": "^6.2.0",
"jest": "^29.6.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/dashboard-backend/src/__tests__/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
*/

import process from 'process';
import { setup, teardown } from '../helpers/tests/appBuilder';

import { setup, teardown } from '@/helpers/tests/appBuilder';

const mockProcessExit = jest.fn();
(process as any).exit = mockProcessExit.mockImplementation(code => {
Expand Down
56 changes: 29 additions & 27 deletions packages/dashboard-backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@
* Red Hat, Inc. - initial API and implementation
*/

import 'reflect-metadata';

import { helpers } from '@eclipse-che/common';
import { FastifyInstance } from 'fastify';
import 'reflect-metadata';
import parseArgs from './helpers/parseArgs';
import { isLocalRun, registerLocalRun } from './localRun';
import { registerCors } from './plugins/cors';
import { registerStaticServer } from './plugins/staticServer';
import { registerSwagger } from './plugins/swagger';
import { registerWebSocket } from './plugins/webSocket';
import { registerClusterConfigRoute } from './routes/api/clusterConfig';
import { registerClusterInfoRoute } from './routes/api/clusterInfo';
import { registerDevfileSchemaRoute } from './routes/api/devfileSchema';
import { registerDevworkspaceResourcesRoute } from './routes/api/devworkspaceResources';
import { registerDevworkspacesRoutes } from './routes/api/devworkspaces';
import { registerDevWorkspaceTemplates } from './routes/api/devworkspaceTemplates';
import { registerDockerConfigRoutes } from './routes/api/dockerConfig';
import { registerEventsRoutes } from './routes/api/events';
import { registerKubeConfigRoute } from './routes/api/kubeConfig';
import { registerPodmanLoginRoute } from './routes/api/podmanLogin';
import { registerPersonalAccessTokenRoutes } from './routes/api/personalAccessToken';
import { registerPodsRoutes } from './routes/api/pods';
import { registerServerConfigRoute } from './routes/api/serverConfig';
import { registerUserProfileRoute } from './routes/api/userProfile';
import { registerWebsocket } from './routes/api/websocket';
import { registerYamlResolverRoute } from './routes/api/yamlResolver';
import { registerFactoryAcceptanceRedirect } from './routes/factoryAcceptanceRedirect';
import { registerWorkspaceRedirect } from './routes/workspaceRedirect';
import { registerGitConfigRoutes } from './routes/api/gitConfig';
import { registerGettingStartedSamplesRoutes } from './routes/api/gettingStartedSample';

import parseArgs from '@/helpers/parseArgs';
import { isLocalRun, registerLocalRun } from '@/localRun';
import { registerCors } from '@/plugins/cors';
import { registerStaticServer } from '@/plugins/staticServer';
import { registerSwagger } from '@/plugins/swagger';
import { registerWebSocket } from '@/plugins/webSocket';
import { registerClusterConfigRoute } from '@/routes/api/clusterConfig';
import { registerClusterInfoRoute } from '@/routes/api/clusterInfo';
import { registerDevfileSchemaRoute } from '@/routes/api/devfileSchema';
import { registerDevworkspaceResourcesRoute } from '@/routes/api/devworkspaceResources';
import { registerDevworkspacesRoutes } from '@/routes/api/devworkspaces';
import { registerDevWorkspaceTemplates } from '@/routes/api/devworkspaceTemplates';
import { registerDockerConfigRoutes } from '@/routes/api/dockerConfig';
import { registerEventsRoutes } from '@/routes/api/events';
import { registerGettingStartedSamplesRoutes } from '@/routes/api/gettingStartedSample';
import { registerGitConfigRoutes } from '@/routes/api/gitConfig';
import { registerKubeConfigRoute } from '@/routes/api/kubeConfig';
import { registerPersonalAccessTokenRoutes } from '@/routes/api/personalAccessToken';
import { registerPodmanLoginRoute } from '@/routes/api/podmanLogin';
import { registerPodsRoutes } from '@/routes/api/pods';
import { registerServerConfigRoute } from '@/routes/api/serverConfig';
import { registerUserProfileRoute } from '@/routes/api/userProfile';
import { registerWebsocket } from '@/routes/api/websocket';
import { registerYamlResolverRoute } from '@/routes/api/yamlResolver';
import { registerFactoryAcceptanceRedirect } from '@/routes/factoryAcceptanceRedirect';
import { registerWorkspaceRedirect } from '@/routes/workspaceRedirect';

export default async function buildApp(server: FastifyInstance): Promise<void> {
const cheHost = process.env.CHE_HOST as string;
Expand Down
3 changes: 2 additions & 1 deletion packages/dashboard-backend/src/constants/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
* Red Hat, Inc. - initial API and implementation
*/

import { dockerConfigExample, devWorkspaceResourcesExample } from './examples';
import { JSONSchema7 } from 'json-schema';

import { devWorkspaceResourcesExample, dockerConfigExample } from '@/constants/examples';

export const authenticationHeaderSchema: JSONSchema7 = {
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* Red Hat, Inc. - initial API and implementation
*/

import { IDevWorkspaceClient } from '..';
import {
IDevWorkspaceApi,
IDevWorkspaceTemplateApi,
Expand All @@ -22,7 +21,9 @@ import {
IPodApi,
IServerConfigApi,
IUserProfileApi,
} from '../types';
} from '@/devworkspaceClient/types';

import { IDevWorkspaceClient } from '..';

export class DevWorkspaceClient implements IDevWorkspaceClient {
get eventApi(): IEventApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@

import * as mockClientNode from '@kubernetes/client-node';
import { KubeConfig } from '@kubernetes/client-node';

import { DevWorkspaceApiService } from '@/devworkspaceClient/services/devWorkspaceApi';
import { DevWorkspaceTemplateApiService } from '@/devworkspaceClient/services/devWorkspaceTemplateApi';
import { DockerConfigApiService } from '@/devworkspaceClient/services/dockerConfigApi';
import { EventApiService } from '@/devworkspaceClient/services/eventApi';
import { GettingStartedSamplesApiService } from '@/devworkspaceClient/services/gettingStartedSamplesApi';
import { GitConfigApiService } from '@/devworkspaceClient/services/gitConfigApi';
import { KubeConfigApiService } from '@/devworkspaceClient/services/kubeConfigApi';
import { LogsApiService } from '@/devworkspaceClient/services/logsApi';
import { PodApiService } from '@/devworkspaceClient/services/podApi';
import { ServerConfigApiService } from '@/devworkspaceClient/services/serverConfigApi';
import { UserProfileApiService } from '@/devworkspaceClient/services/userProfileApi';

import { DevWorkspaceClient } from '..';
import { DevWorkspaceApiService } from '../services/devWorkspaceApi';
import { DevWorkspaceTemplateApiService } from '../services/devWorkspaceTemplateApi';
import { DockerConfigApiService } from '../services/dockerConfigApi';
import { EventApiService } from '../services/eventApi';
import { GitConfigApiService } from '../services/gitConfigApi';
import { KubeConfigApiService } from '../services/kubeConfigApi';
import { LogsApiService } from '../services/logsApi';
import { PodApiService } from '../services/podApi';
import { ServerConfigApiService } from '../services/serverConfigApi';
import { UserProfileApiService } from '../services/userProfileApi';
import { GettingStartedSamplesApiService } from '../services/gettingStartedSamplesApi';

jest.mock('../services/devWorkspaceApi.ts');

Expand Down
29 changes: 15 additions & 14 deletions packages/dashboard-backend/src/devworkspaceClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
*/

import * as k8s from '@kubernetes/client-node';
import { DevWorkspaceApiService } from './services/devWorkspaceApi';
import { DevWorkspaceTemplateApiService } from './services/devWorkspaceTemplateApi';
import { DockerConfigApiService } from './services/dockerConfigApi';
import { EventApiService } from './services/eventApi';
import { GettingStartedSamplesApiService } from './services/gettingStartedSamplesApi';
import { GitConfigApiService } from './services/gitConfigApi';
import { KubeConfigApiService } from './services/kubeConfigApi';
import { LogsApiService } from './services/logsApi';
import { PersonalAccessTokenService } from './services/personalAccessTokenApi';
import { PodApiService } from './services/podApi';
import { PodmanApiService } from './services/podmanApi';
import { ServerConfigApiService } from './services/serverConfigApi';
import { UserProfileApiService } from './services/userProfileApi';

import { DevWorkspaceApiService } from '@/devworkspaceClient/services/devWorkspaceApi';
import { DevWorkspaceTemplateApiService } from '@/devworkspaceClient/services/devWorkspaceTemplateApi';
import { DockerConfigApiService } from '@/devworkspaceClient/services/dockerConfigApi';
import { EventApiService } from '@/devworkspaceClient/services/eventApi';
import { GettingStartedSamplesApiService } from '@/devworkspaceClient/services/gettingStartedSamplesApi';
import { GitConfigApiService } from '@/devworkspaceClient/services/gitConfigApi';
import { KubeConfigApiService } from '@/devworkspaceClient/services/kubeConfigApi';
import { LogsApiService } from '@/devworkspaceClient/services/logsApi';
import { PersonalAccessTokenService } from '@/devworkspaceClient/services/personalAccessTokenApi';
import { PodApiService } from '@/devworkspaceClient/services/podApi';
import { PodmanApiService } from '@/devworkspaceClient/services/podmanApi';
import { ServerConfigApiService } from '@/devworkspaceClient/services/serverConfigApi';
import { UserProfileApiService } from '@/devworkspaceClient/services/userProfileApi';
import {
IDevWorkspaceApi,
IDevWorkspaceClient,
Expand All @@ -39,7 +40,7 @@ import {
IPodmanApi,
IServerConfigApi,
IUserProfileApi,
} from './types';
} from '@/devworkspaceClient/types';

export * from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import {
V1alpha2DevWorkspace,
} from '@devfile/api';
import { api } from '@eclipse-che/common';
import { IPatch } from '@eclipse-che/common/src/dto/api';
import * as mockClient from '@kubernetes/client-node';
import { CustomObjectsApi } from '@kubernetes/client-node';
import { IncomingMessage } from 'http';
import { DevWorkspaceApiService } from '../devWorkspaceApi';

import { DevWorkspaceApiService } from '@/devworkspaceClient/services/devWorkspaceApi';

const namespace = 'user-che';
const name = 'wksp-name';
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('DevWorkspace API Service', () => {
});

test('patching', async () => {
const patches: IPatch[] = [
const patches: api.IPatch[] = [
{
op: 'replace',
path: '/metadata/annotations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import {
devworkspacetemplatePlural,
V1alpha2DevWorkspaceTemplate,
} from '@devfile/api';
import { IPatch } from '@eclipse-che/common/src/dto/api';
import { api } from '@eclipse-che/common';
import * as mockClient from '@kubernetes/client-node';
import { CustomObjectsApi } from '@kubernetes/client-node';

import {
DevWorkspaceTemplateApiService,
DevWorkspaceTemplateList,
} from '../devWorkspaceTemplateApi';
} from '@/devworkspaceClient/services/devWorkspaceTemplateApi';

const namespace = 'user-che';
const name = 'tmpl-name';
Expand Down Expand Up @@ -128,7 +129,7 @@ describe('DevWorkspaceTemplate API Service', () => {
});

test('patching', async () => {
const patches: IPatch[] = [
const patches: api.IPatch[] = [
{
op: 'replace',
path: '/metadata/annotations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@

import * as mockClient from '@kubernetes/client-node';
import { CoreV1Api, V1Secret } from '@kubernetes/client-node';
import { DockerConfigApiService, SECRET_KEY, SECRET_NAME } from '../dockerConfigApi';

import {
DockerConfigApiService,
SECRET_KEY,
SECRET_NAME,
} from '@/devworkspaceClient/services/dockerConfigApi';

describe('Docker Config API Service', () => {
let dockerConfigService: DockerConfigApiService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import { api } from '@eclipse-che/common';
import * as mockClient from '@kubernetes/client-node';
import { CoreV1Api, CoreV1Event, V1Status } from '@kubernetes/client-node';
import { EventApiService } from '../eventApi';

import { EventApiService } from '@/devworkspaceClient/services/eventApi';

jest.mock('../helpers/prepareCustomObjectWatch');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
* Red Hat, Inc. - initial API and implementation
*/

import * as mockClient from '@kubernetes/client-node';
import { GettingStartedSamplesApiService } from '../gettingStartedSamplesApi';
import { api } from '@eclipse-che/common';
import * as mockClient from '@kubernetes/client-node';

import { GettingStartedSamplesApiService } from '@/devworkspaceClient/services/gettingStartedSamplesApi';

describe('Getting Started Samples API Service', () => {
const env = process.env;
Expand Down
Loading

0 comments on commit 8875bd2

Please sign in to comment.