Skip to content

Commit 952c465

Browse files
committed
lint: set prettier arrowParens=always
Problem: javascript arrow functions allow braces `{ ... }` to surround an expression without a `return`, which leads to bugs such as aws#3659 aws#3662 Example: return supplementalContexts.filter(item => { item.content.trim().length !== 0 }) should be: return supplementalContexts.filter(item => item.content.trim().length !== 0) Solution: - Set prettier `arrowParens=always`. This is the default, explained here: https://prettier.io/docs/en/options.html#arrow-function-parentheses > At first glance, avoiding parentheses may look like a better choice because of less visual noise. However, when Prettier removes parentheses, it becomes harder to add type annotations, extra arguments or default values as well as making other changes. Consistent use of parentheses provides a better developer experience when editing real codebases, which justifies the default value for the option. - Note: this is equivalent to the eslint `@stylistic/no-confusing-arrow` rule. - https://eslint.style/packages/default#stylistic-eslint-plugin - https://eslint.style/rules/default/no-confusing-arrow
1 parent eae810b commit 952c465

30 files changed

+82
-82
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"singleQuote": true,
1717
"semi": false,
1818
"bracketSpacing": true,
19-
"arrowParens": "avoid",
19+
"arrowParens": "always",
2020
"endOfLine": "lf"
2121
},
2222
"scripts": {

packages/amazonq/scripts/build/copyFiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface CopyTask {
2626
}
2727

2828
const tasks: CopyTask[] = [
29-
...['LICENSE', 'NOTICE'].map(f => {
29+
...['LICENSE', 'NOTICE'].map((f) => {
3030
return { target: path.join('../../', f), destination: path.join(projectRoot, f) }
3131
}),
3232

packages/amazonq/scripts/build/syncPackageJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function main() {
2525
const coreLibPackageJson = JSON.parse(fs.readFileSync(coreLibPackageJsonFile, { encoding: 'utf-8' }))
2626

2727
const coreSettings = coreLibPackageJson.contributes.configuration.properties
28-
Object.keys(coreSettings).forEach(key => {
28+
Object.keys(coreSettings).forEach((key) => {
2929
if (key.startsWith('amazonQ')) {
3030
packageJson.contributes.configuration.properties[key] = coreSettings[key]
3131
}

packages/amazonq/src/extensionCommon.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const amazonQContextPrefix = 'amazonq'
4444
*/
4545
export async function activateAmazonQCommon(context: vscode.ExtensionContext, isWeb: boolean) {
4646
initialize(context, isWeb)
47-
const homeDirLogs = await fs.init(context, homeDir => {
47+
const homeDirLogs = await fs.init(context, (homeDir) => {
4848
void messages.showViewLogsMessage(`Invalid home directory (check $HOME): "${homeDir}"`)
4949
})
5050
errors.init(fs.getUsername(), env.isAutomation())
@@ -73,12 +73,12 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
7373
} and older. Your AWS Toolkit was updated to version 3.0 or later.`,
7474
'Reload Now'
7575
)
76-
.then(async resp => {
76+
.then(async (resp) => {
7777
if (resp === 'Reload Now') {
7878
await vscode.commands.executeCommand('workbench.action.reloadWindow')
7979
}
8080
}),
81-
reason => {
81+
(reason) => {
8282
getLogger().error('workbench.extensions.installExtension failed: %O', reason)
8383
}
8484
)

packages/amazonq/test/e2e/amazonq/featureDev.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ describe('Amazon Q Feature Dev', function () {
7878

7979
function waitForButtons(buttons: FollowUpTypes[]) {
8080
return tab.waitForEvent(() => {
81-
return buttons.every(value => tab.hasButton(value))
81+
return buttons.every((value) => tab.hasButton(value))
8282
})
8383
}
8484

8585
async function waitForText(text: string) {
8686
await tab.waitForEvent(
8787
() => {
88-
return tab.getChatItems().some(chatItem => chatItem.body === text)
88+
return tab.getChatItems().some((chatItem) => chatItem.body === text)
8989
},
9090
{
9191
waitIntervalInMs: 250,

packages/amazonq/test/e2e/amazonq/framework/framework.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class qTestingFramework {
6262
* This implements the VSCode -> Mynah UI flow
6363
*/
6464
this.disposables.push(
65-
DefaultAmazonQAppInitContext.instance.getAppsToWebViewMessageListener().onMessage(async message => {
65+
DefaultAmazonQAppInitContext.instance.getAppsToWebViewMessageListener().onMessage(async (message) => {
6666
// Emulate the json format of postMessage
6767
const event = {
6868
data: JSON.stringify(message),

packages/amazonq/test/e2e/amazonq/framework/jsdomInjector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export function injectJSDOM() {
2828
})
2929

3030
// jsdom doesn't have support for structuredClone. See https://github.com/jsdom/jsdom/issues/3363
31-
global.structuredClone = val => JSON.parse(JSON.stringify(val))
31+
global.structuredClone = (val) => JSON.parse(JSON.stringify(val))
3232
}

packages/amazonq/test/e2e/amazonq/framework/messenger.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Messenger {
5151
}
5252

5353
const lastChatItem = this.getChatItems().pop()
54-
const option = lastChatItem?.followUp?.options?.filter(option => option.type === type)
54+
const option = lastChatItem?.followUp?.options?.filter((option) => option.type === type)
5555
if (!option || option.length > 1) {
5656
assert.fail('Could not find follow up option')
5757
}
@@ -61,9 +61,9 @@ export class Messenger {
6161

6262
findCommand(command: string) {
6363
return this.getCommands()
64-
.map(groups => groups.commands)
64+
.map((groups) => groups.commands)
6565
.flat()
66-
.filter(commands => commands.command === command)
66+
.filter((commands) => commands.command === command)
6767
}
6868

6969
getCommands() {
@@ -82,7 +82,7 @@ export class Messenger {
8282
return (
8383
this.getChatItems()
8484
.pop()
85-
?.followUp?.options?.map(opt => opt.type)
85+
?.followUp?.options?.map((opt) => opt.type)
8686
.includes(type) ?? false
8787
)
8888
}

packages/amazonq/test/e2e/amazonq/framework/text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function verifyTextOrder(chatItems: ChatItem[], expectedText: RegExp[]) {
2222
}
2323

2424
if (currInd !== expectedText.length) {
25-
const chatItemBodies = chatItems.filter(item => item !== undefined).map(item => item.body)
25+
const chatItemBodies = chatItems.filter((item) => item !== undefined).map((item) => item.body)
2626
const expected = expectedText.join(', ')
2727
assert.fail(`Items did not appear in expected order. Found ${chatItemBodies} but expected ${expected}`)
2828
}

packages/amazonq/test/unit/amazonqGumby/transformFileHandler.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ describe('Amazon Q Transform - transformFileHandler tests', function () {
4545
</dependencies>
4646
</DependencyUpdatesReport>
4747
`
48-
const { latestVersion, majorVersions, minorVersions, status } = await parseVersionsListFromPomFile(
49-
testXmlReport
50-
)
48+
const { latestVersion, majorVersions, minorVersions, status } =
49+
await parseVersionsListFromPomFile(testXmlReport)
5150

5251
assert.strictEqual(latestVersion, '1.18.32')
5352
assert.strictEqual(minorVersions[0], '0.12.0')

0 commit comments

Comments
 (0)