Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ module.exports = {
message:
'Avoid child_process, use ChildProcess from `shared/utilities/processUtils.ts` instead.',
},
{
name: '..',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents importing from index.ts files in other paths? E.g. ./adjacentFolder/folderWithIndex/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, but I think the circular dependency is only a problem when the index.ts is importing from the current file as well. This should only happen when the index.ts is a parent rather than an adjacent folder.

There is another case where the index.ts is more than one level up, but I wasn't able to find any instances of this in the toolkit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found the most common pitfall to be having a file that depends on an index.ts that is exporting something depends on your file. E.g.

// connection.ts
import { logger } from './logger' // index.ts import
// logger/index.ts
export logger from './logger'
export loggerUtil from './loggerUtil'
// logger/loggerUtil.ts
import { connectionType } from '../connection'

connection.ts > logger/index.ts > loggerUtils.ts > connection.ts,
when in reality we just want connection.ts > logger/logger.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yeah unfortunately, this won't address that. I would also imagine it would be hard to catch via lint rule.

message:
'Avoid importing from index.ts files as it can lead to circular dependencies. Import from the module directly instead.',
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
throwIfCancelled,
} from '../service/testGenHandler'
import path from 'path'
import { testGenState } from '..'
import { testGenState } from '../models/model'
import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
import { ChildProcess, spawn } from 'child_process' // eslint-disable-line no-restricted-imports
import { BuildStatus } from '../../amazonqTest/chat/session/session'
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/codewhisperer/service/testGenHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import CodeWhispererUserClient, {
import { CreateUploadUrlError, InvalidSourceZipError, TestGenFailedError, TestGenTimedOutError } from '../models/errors'
import { getMd5, uploadArtifactToS3 } from './securityScanHandler'
import { fs, randomUUID, sleep, tempDirPath } from '../../shared'
import { ShortAnswer, TestGenerationJobStatus, testGenState } from '..'
import { ShortAnswer, testGenState } from '../models/model'
import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
import { createCodeWhispererChatStreamingClient } from '../../shared/clients/codewhispererChatClient'
import { downloadExportResultArchive } from '../../shared/utilities/download'
Expand Down Expand Up @@ -182,9 +182,9 @@ export async function pollTestJobStatus(
}
ChatSessionManager.Instance.getSession().shortAnswer = shortAnswer
}
if (resp.testGenerationJob?.status !== TestGenerationJobStatus.IN_PROGRESS) {
if (resp.testGenerationJob?.status !== CodeWhispererConstants.TestGenerationJobStatus.IN_PROGRESS) {
// This can be FAILED or COMPLETED
status = resp.testGenerationJob?.status as TestGenerationJobStatus
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
logger.verbose(`testgen job status: ${status}`)
logger.verbose(`Complete polling test job status.`)
break
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shared/env/resolveEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import * as crypto from 'crypto'
import { DevSettings } from '../settings'
import { getLogger } from '..'
import { getLogger } from '../logger/logger'
import { ToolkitError } from '../errors'
import { userInfo } from 'os'
import path from 'path'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shared/utilities/downloadPatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AdmZip from 'adm-zip'
import { getLogger } from '../logger/logger'
import * as vscode from 'vscode'
import * as path from 'path'
import { ToolkitError } from '..'
import { ToolkitError } from '../errors'

// Get pattern code and save it in temporary folder
async function fetchUrl(owner: string, repoName: string, assetName: string): Promise<Buffer> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shared/utilities/pollingSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { globals } from '..'
import globals from '../../shared/extensionGlobals'

/**
* A useful abstraction that does the following:
Expand Down
Loading