Skip to content

Commit

Permalink
Merge aws#5307 lint: use gitignore, enforce prettier rules
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk3 authored Jul 12, 2024
2 parents eae810b + 2d2c919 commit 56b1c4b
Show file tree
Hide file tree
Showing 557 changed files with 2,219 additions and 2,110 deletions.
24 changes: 0 additions & 24 deletions .eslintignore

This file was deleted.

4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/recommended',
'prettier',
// "Add this as the _last_ item in the extends array, so that eslint-config-prettier has the
// opportunity to override other configs." https://github.com/prettier/eslint-plugin-prettier
'plugin:prettier/recommended',
],
rules: {
curly: 2, // Enforce braces on "if"/"for"/etc.
Expand Down
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Note: also used for `eslint --ignore-path`.

out
dist
node_modules
Expand Down Expand Up @@ -27,15 +29,15 @@ packages/core/src/shared/telemetry/vscodeTelemetry.json
.test-reports

# Auto generated type definitions
packages/core/src/shared/telemetry/clienttelemetry.d.ts
packages/core/src/codewhisperer/client/codewhispererclient.d.ts
packages/core/src/codewhisperer/client/codewhispereruserclient.d.ts
packages/core/src/amazonqFeatureDev/client/featuredevproxyclient.d.ts
packages/core/src/auth/sso/oidcclientpkce.d.ts
**/src/shared/telemetry/clienttelemetry.d.ts
**/src/codewhisperer/client/codewhispererclient.d.ts
**/src/codewhisperer/client/codewhispereruserclient.d.ts
**/src/amazonqFeatureDev/client/featuredevproxyclient.d.ts
**/src/auth/sso/oidcclientpkce.d.ts

# Generated by tests
packages/core/src/testFixtures/**/bin
packages/core/src/testFixtures/**/obj
**/src/testFixtures/**/bin
**/src/testFixtures/**/obj

# Generated by copyFiles.ts
packages/*/LICENSE
Expand Down
77 changes: 77 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"singleQuote": true,
"semi": false,
"bracketSpacing": true,
"arrowParens": "avoid",
"arrowParens": "always",
"endOfLine": "lf"
},
"scripts": {
Expand All @@ -32,10 +32,8 @@
"package": "npm run package -w packages/toolkit -w packages/amazonq",
"newChange": "echo 'Must specify subproject/workspace with -w packages/<subproject>' && false",
"createRelease": "echo 'Must specify subproject/workspace with -w packages/<subproject>' && false",
"format": "prettier --check plugins && npm run format -w packages/ --if-present",
"formatfix": "prettier --write plugins && npm run formatfix -w packages/ --if-present",
"lint": "npm run lint -w packages/ --if-present && npm run format",
"lintfix": "eslint -c .eslintrc.js --fix --ext .ts packages plugins && npm run formatfix",
"lint": "npm run lint -w packages/ --if-present",
"lintfix": "eslint -c .eslintrc.js --ignore-path .gitignore --ignore-pattern '**/*.json' --ignore-pattern '**/*.gen.ts' --ignore-pattern '**/types/*.d.ts' --ignore-pattern '**/src/testFixtures/**' --ignore-pattern '**/resources/js/graphStateMachine.js' --fix --ext .ts packages plugins",
"clean": "npm run clean -w packages/ -w plugins/",
"reset": "npm run clean && ts-node ./scripts/clean.ts node_modules && npm install",
"generateNonCodeFiles": "npm run generateNonCodeFiles -w packages/ --if-present"
Expand All @@ -55,6 +53,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-aws-toolkits": "file:plugins/eslint-plugin-aws-toolkits",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-security-node": "^1.1.4",
"eslint-plugin-unicorn": "^54.0.0",
"husky": "^9.0.7",
Expand Down
4 changes: 1 addition & 3 deletions packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
"compile": "npm run clean && npm run buildScripts && webpack --mode development",
"compileOnly": "tsc -p ./",
"package": "ts-node ../../scripts/package.ts",
"format": "prettier --ignore-path ../../.prettierignore --check src scripts",
"formatfix": "prettier --ignore-path ../../.prettierignore --write src scripts",
"lint": "echo 'Nothing to lint yet!'",
"lint": "true",
"watch": "npm run clean && npm run buildScripts && tsc -watch -p ./",
"testCompile": "npm run clean && npm run buildScripts && npm run compileOnly",
"test": "npm run testCompile && c8 ts-node ../core/scripts/test/test.ts dist/test/unit/index.js ../core/dist/src/testFixtures/workspaceFolder",
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/scripts/build/copyFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface CopyTask {
}

const tasks: CopyTask[] = [
...['LICENSE', 'NOTICE'].map(f => {
...['LICENSE', 'NOTICE'].map((f) => {
return { target: path.join('../../', f), destination: path.join(projectRoot, f) }
}),

Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/scripts/build/syncPackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function main() {
const coreLibPackageJson = JSON.parse(fs.readFileSync(coreLibPackageJsonFile, { encoding: 'utf-8' }))

const coreSettings = coreLibPackageJson.contributes.configuration.properties
Object.keys(coreSettings).forEach(key => {
Object.keys(coreSettings).forEach((key) => {
if (key.startsWith('amazonQ')) {
packageJson.contributes.configuration.properties[key] = coreSettings[key]
}
Expand Down
6 changes: 3 additions & 3 deletions packages/amazonq/src/extensionCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const amazonQContextPrefix = 'amazonq'
*/
export async function activateAmazonQCommon(context: vscode.ExtensionContext, isWeb: boolean) {
initialize(context, isWeb)
const homeDirLogs = await fs.init(context, homeDir => {
const homeDirLogs = await fs.init(context, (homeDir) => {
void messages.showViewLogsMessage(`Invalid home directory (check $HOME): "${homeDir}"`)
})
errors.init(fs.getUsername(), env.isAutomation())
Expand Down Expand Up @@ -73,12 +73,12 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
} and older. Your AWS Toolkit was updated to version 3.0 or later.`,
'Reload Now'
)
.then(async resp => {
.then(async (resp) => {
if (resp === 'Reload Now') {
await vscode.commands.executeCommand('workbench.action.reloadWindow')
}
}),
reason => {
(reason) => {
getLogger().error('workbench.extensions.installExtension failed: %O', reason)
}
)
Expand Down
4 changes: 2 additions & 2 deletions packages/amazonq/test/e2e/amazonq/featureDev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ describe('Amazon Q Feature Dev', function () {

function waitForButtons(buttons: FollowUpTypes[]) {
return tab.waitForEvent(() => {
return buttons.every(value => tab.hasButton(value))
return buttons.every((value) => tab.hasButton(value))
})
}

async function waitForText(text: string) {
await tab.waitForEvent(
() => {
return tab.getChatItems().some(chatItem => chatItem.body === text)
return tab.getChatItems().some((chatItem) => chatItem.body === text)
},
{
waitIntervalInMs: 250,
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/test/e2e/amazonq/framework/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class qTestingFramework {
* This implements the VSCode -> Mynah UI flow
*/
this.disposables.push(
DefaultAmazonQAppInitContext.instance.getAppsToWebViewMessageListener().onMessage(async message => {
DefaultAmazonQAppInitContext.instance.getAppsToWebViewMessageListener().onMessage(async (message) => {
// Emulate the json format of postMessage
const event = {
data: JSON.stringify(message),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export function injectJSDOM() {
})

// jsdom doesn't have support for structuredClone. See https://github.com/jsdom/jsdom/issues/3363
global.structuredClone = val => JSON.parse(JSON.stringify(val))
global.structuredClone = (val) => JSON.parse(JSON.stringify(val))
}
8 changes: 4 additions & 4 deletions packages/amazonq/test/e2e/amazonq/framework/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Messenger {
}

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

findCommand(command: string) {
return this.getCommands()
.map(groups => groups.commands)
.map((groups) => groups.commands)
.flat()
.filter(commands => commands.command === command)
.filter((commands) => commands.command === command)
}

getCommands() {
Expand All @@ -82,7 +82,7 @@ export class Messenger {
return (
this.getChatItems()
.pop()
?.followUp?.options?.map(opt => opt.type)
?.followUp?.options?.map((opt) => opt.type)
.includes(type) ?? false
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/test/e2e/amazonq/framework/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function verifyTextOrder(chatItems: ChatItem[], expectedText: RegExp[]) {
}

if (currInd !== expectedText.length) {
const chatItemBodies = chatItems.filter(item => item !== undefined).map(item => item.body)
const chatItemBodies = chatItems.filter((item) => item !== undefined).map((item) => item.body)
const expected = expectedText.join(', ')
assert.fail(`Items did not appear in expected order. Found ${chatItemBodies} but expected ${expected}`)
}
Expand Down
4 changes: 4 additions & 0 deletions packages/amazonq/test/unit/amazonq/lsp/lspClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import * as sinon from 'sinon'
import assert from 'assert'
import { globals } from 'aws-core-vscode/shared'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ describe('Amazon Q Transform - transformFileHandler tests', function () {
</dependencies>
</DependencyUpdatesReport>
`
const { latestVersion, majorVersions, minorVersions, status } = await parseVersionsListFromPomFile(
testXmlReport
)
const { latestVersion, majorVersions, minorVersions, status } =
await parseVersionsListFromPomFile(testXmlReport)

assert.strictEqual(latestVersion, '1.18.32')
assert.strictEqual(minorVersions[0], '0.12.0')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('DiffModel', function () {

const workspacePath = 'workspace'

sinon.replace(fs, 'existsSync', path => {
sinon.replace(fs, 'existsSync', (path) => {
const pathStr = path.toString()
if (pathStr.includes(workspacePath)) {
return false
Expand All @@ -42,7 +42,7 @@ describe('DiffModel', function () {

const workspacePath = os.tmpdir()

sinon.replace(fs, 'existsSync', path => true)
sinon.replace(fs, 'existsSync', (path) => true)

fs.writeFileSync(
path.join(workspacePath, 'README.md'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('codewhisperer', async function () {
ideCategory: 'VSCODE',
operatingSystem: getOperatingSystem(),
product: 'CodeWhisperer',
clientId: await getClientId(globals.context.globalState),
clientId: getClientId(globals.context.globalState),
}

await codeWhispererClient.sendTelemetryEvent({ telemetryEvent: userTriggerDecisionPayload })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe('keyStrokeHandler', function () {
['function suggestedByIntelliSense():', DocumentChangedSource.Unknown],
]

cases.forEach(tuple => {
cases.forEach((tuple) => {
const input = tuple[0]
const expected = tuple[1]
it(`test input ${input} should return ${expected}`, function () {
Expand Down
Loading

0 comments on commit 56b1c4b

Please sign in to comment.