Skip to content

Commit 87dc533

Browse files
committed
finish migrating Q
1 parent 09141a7 commit 87dc533

File tree

8 files changed

+27
-29
lines changed

8 files changed

+27
-29
lines changed

packages/amazonq/src/inlineChat/controller/inlineChatController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class InlineChatController {
156156
}
157157

158158
private async reset() {
159-
this.listeners.forEach((listener) => listener.dispose())
159+
await Promise.all(this.listeners.map((l) => l.dispose()))
160160
this.listeners = []
161161

162162
this.task = undefined

packages/amazonq/src/inlineChat/output/computeDiff.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5-
import { type LinesOptions, diffLines, Change } from 'diff'
5+
import { type LinesOptions, diffLines } from 'diff'
66
import * as vscode from 'vscode'
77
import { InlineTask, TextDiff } from '../controller/inlineTask'
88

@@ -24,8 +24,7 @@ export function computeDiff(response: string, inlineTask: InlineTask, isPartialD
2424

2525
const textDiff: TextDiff[] = []
2626
let startLine = selectedRange.start.line
27-
28-
diffs.forEach((part: Change) => {
27+
for (const part of diffs) {
2928
const count = part.count ?? 0
3029
if (part.removed) {
3130
if (part.value !== '\n') {
@@ -49,7 +48,7 @@ export function computeDiff(response: string, inlineTask: InlineTask, isPartialD
4948
}
5049
}
5150
startLine += count
52-
})
51+
}
5352
inlineTask.diff = textDiff
5453
return textDiff
5554
}

packages/amazonq/test/unit/codewhisperer/service/keyStrokeHandler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ describe('keyStrokeHandler', function () {
212212
['function suggestedByIntelliSense():', DocumentChangedSource.Unknown],
213213
]
214214

215-
cases.forEach((tuple) => {
215+
for (const tuple of cases) {
216216
const input = tuple[0]
217217
const expected = tuple[1]
218218
it(`test input ${input} should return ${expected}`, function () {
@@ -221,7 +221,7 @@ describe('keyStrokeHandler', function () {
221221
).checkChangeSource()
222222
assert.strictEqual(actual, expected)
223223
})
224-
})
224+
}
225225

226226
function createFakeDocumentChangeEvent(str: string): ReadonlyArray<vscode.TextDocumentContentChangeEvent> {
227227
return [

packages/amazonq/test/unit/codewhisperer/util/crossFileContextUtil.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,12 @@ describe('crossFileContextUtil', function () {
241241
const actual = await crossFile.getCrossFileCandidates(editor)
242242

243243
assert.ok(actual.length === 5)
244-
actual.forEach((actualFile, index) => {
244+
for (const item of actual.map((v: string, i: number) => [i, v] as const)) {
245+
const [index, actualFile] = item
245246
const expectedFile = path.join(tempFolder, expectedFilePaths[index])
246247
assert.strictEqual(normalize(expectedFile), normalize(actualFile))
247248
assert.ok(areEqual(tempFolder, actualFile, expectedFile))
248-
})
249+
}
249250
})
250251
})
251252

@@ -264,7 +265,7 @@ describe('crossFileContextUtil', function () {
264265
await closeAllEditors()
265266
})
266267

267-
fileExtLists.forEach((fileExt) => {
268+
for (const fileExt of fileExtLists) {
268269
it('should be empty if userGroup is control', async function () {
269270
const editor = await toTextEditor('content-1', `file-1.${fileExt}`, tempFolder)
270271
await toTextEditor('content-2', `file-2.${fileExt}`, tempFolder, { preview: false })
@@ -277,7 +278,7 @@ describe('crossFileContextUtil', function () {
277278

278279
assert.ok(actual && actual.supplementalContextItems.length === 0)
279280
})
280-
})
281+
}
281282
})
282283

283284
describe.skip('partial support - crossfile group', function () {
@@ -294,8 +295,7 @@ describe('crossFileContextUtil', function () {
294295
afterEach(async function () {
295296
await closeAllEditors()
296297
})
297-
298-
fileExtLists.forEach((fileExt) => {
298+
for (const fileExt of fileExtLists) {
299299
it('should be non empty if usergroup is Crossfile', async function () {
300300
const editor = await toTextEditor('content-1', `file-1.${fileExt}`, tempFolder)
301301
await toTextEditor('content-2', `file-2.${fileExt}`, tempFolder, { preview: false })
@@ -308,7 +308,7 @@ describe('crossFileContextUtil', function () {
308308

309309
assert.ok(actual && actual.supplementalContextItems.length !== 0)
310310
})
311-
})
311+
}
312312
})
313313

314314
describe('full support', function () {
@@ -329,7 +329,7 @@ describe('crossFileContextUtil', function () {
329329
await closeAllEditors()
330330
})
331331

332-
fileExtLists.forEach((fileExt) => {
332+
for (const fileExt of fileExtLists) {
333333
it(`supplemental context for file ${fileExt} should be non empty`, async function () {
334334
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').returns('control')
335335
sinon
@@ -353,7 +353,7 @@ describe('crossFileContextUtil', function () {
353353

354354
assert.ok(actual && actual.supplementalContextItems.length !== 0)
355355
})
356-
})
356+
}
357357
})
358358

359359
describe('splitFileToChunks', function () {

packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,12 @@ describe('editorContext', function () {
9494
['typescript', 'ts'],
9595
['c', 'c'],
9696
])
97-
98-
languageToExtension.forEach((extension, language) => {
97+
for (const language of languageToExtension.keys()) {
9998
const editor = createMockTextEditor('', 'test.ipynb', language, 1, 17)
10099
const actual = EditorContext.getFileRelativePath(editor)
101-
const expected = 'test.' + extension
100+
const expected = 'test.' + languageToExtension.get(language)
102101
assert.strictEqual(actual, expected)
103-
})
102+
}
104103
})
105104

106105
it('Should return relative path', async function () {

packages/amazonq/test/unit/codewhisperer/util/runtimeLanguageContext.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,15 @@ describe('runtimeLanguageContext', function () {
5151
beforeEach(async function () {
5252
await resetCodeWhispererGlobalVariables()
5353
})
54-
55-
cases.forEach((tuple) => {
54+
for (const tuple of cases) {
5655
const languageId = tuple[0]
5756
const expected = tuple[1]
5857

5958
it(`should ${expected ? '' : 'not'} support ${languageId}`, function () {
6059
const actual = languageContext.isLanguageSupported(languageId)
6160
assert.strictEqual(actual, expected)
6261
})
63-
})
62+
}
6463

6564
describe('test isLanguageSupported with document as the argument', function () {
6665
const cases: [string, boolean][] = [
@@ -105,7 +104,7 @@ describe('runtimeLanguageContext', function () {
105104
['helloFoo.foo', false],
106105
]
107106

108-
cases.forEach((tuple) => {
107+
for (const tuple of cases) {
109108
const fileName = tuple[0]
110109
const expected = tuple[1]
111110

@@ -114,7 +113,7 @@ describe('runtimeLanguageContext', function () {
114113
const actual = languageContext.isLanguageSupported(doc)
115114
assert.strictEqual(actual, expected)
116115
})
117-
})
116+
}
118117
})
119118
})
120119

@@ -148,14 +147,14 @@ describe('runtimeLanguageContext', function () {
148147
[undefined, 'plaintext'],
149148
]
150149

151-
cases.forEach((tuple) => {
150+
for (const tuple of cases) {
152151
const vscLanguageId = tuple[0]
153152
const expectedCwsprLanguageId = tuple[1]
154153
it(`given vscLanguage ${vscLanguageId} should return ${expectedCwsprLanguageId}`, function () {
155154
const result = runtimeLanguageContext.getLanguageContext(vscLanguageId)
156155
assert.strictEqual(result.language as string, expectedCwsprLanguageId)
157156
})
158-
})
157+
}
159158
})
160159

161160
describe('normalizeLanguage', function () {

packages/amazonq/test/unit/codewhisperer/util/securityScanLanguageContext.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ describe('securityScanLanguageContext', function () {
5151
await resetCodeWhispererGlobalVariables()
5252
})
5353

54-
cases.forEach((tuple) => {
54+
for (const tuple of cases) {
5555
const languageId = tuple[0]
5656
const expected = tuple[1]
5757

5858
it(`should ${expected ? '' : 'not'} support ${languageId}`, function () {
5959
const actual = languageContext.isLanguageSupported(languageId)
6060
assert.strictEqual(actual, expected)
6161
})
62-
})
62+
}
6363
})
6464

6565
describe('normalizeLanguage', function () {

packages/amazonq/test/web/testRunner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function setupMocha() {
3535

3636
function gatherTestFiles() {
3737
// Bundles all files in the current directory matching `*.test`
38+
// eslint-disable-next-line aws-toolkits/no-foreach
3839
const importAll = (r: __WebpackModuleApi.RequireContext) => r.keys().forEach(r)
3940
importAll(require.context('.', true, /\.test$/))
4041
}

0 commit comments

Comments
 (0)