Skip to content

Commit

Permalink
ci: require space at start of // comment
Browse files Browse the repository at this point in the history
Problem:
Inconsistent comment style.

Solution:
Add a lint rule.
  • Loading branch information
justinmk3 committed Nov 27, 2024
1 parent 61d67f8 commit 90b6fce
Show file tree
Hide file tree
Showing 69 changed files with 357 additions and 132 deletions.
16 changes: 15 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
mocha: true,
es2024: true,
},
plugins: ['@typescript-eslint', 'unicorn', 'header', 'security-node', 'aws-toolkits'],
plugins: ['@typescript-eslint', '@stylistic', 'unicorn', 'header', 'security-node', 'aws-toolkits'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
Expand Down Expand Up @@ -113,6 +113,20 @@ module.exports = {
'no-constant-condition': ['error', { checkLoops: false }],
'no-empty': 'off',

// https://eslint.style/rules/default/spaced-comment
// Require space after // comment.
'@stylistic/spaced-comment': [
'error',
'always',
{
block: {
markers: ['!'], // Allow the /*!…*/ license header.
// exceptions: ['*'],
// balanced: true
},
},
],

// Rules from https://github.com/sindresorhus/eslint-plugin-unicorn
// TODO: 'unicorn/no-useless-promise-resolve-reject': 'error',
// TODO: 'unicorn/prefer-at': 'error',
Expand Down
212 changes: 211 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"devDependencies": {
"@aws-toolkits/telemetry": "^1.0.282",
"@playwright/browser-chromium": "^1.43.1",
"@stylistic/eslint-plugin": "^2.11.0",
"@types/he": "^1.2.3",
"@types/vscode": "^1.68.0",
"@types/vscode-webview": "^1.57.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
errors.init(fs.getUsername(), env.isAutomation())
await initializeComputeRegion()

globals.contextPrefix = 'amazonq.' //todo: disconnect from above line
globals.contextPrefix = 'amazonq.' // todo: disconnect from above line

// Avoid activation if older toolkit is installed
// Amazon Q is only compatible with AWS Toolkit >= 3.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/core/resources/js/graphStateMachine.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ zoomoutBtn.addEventListener('click', () => {

// Message passing from extension to webview.
// Capture state machine definition
window.addEventListener('message', event => {
window.addEventListener('message', (event) => {
// event.data is object passed in from postMessage from vscode
const message = event.data
switch (message.command) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/amazonq/lsp/lspController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export class LspController {
})
}
} catch (error) {
//TODO: use telemetry.run()
// TODO: use telemetry.run()
getLogger().error(`LspController: Failed to build index of project`)
telemetry.amazonq_indexWorkspace.emit({
duration: performance.now() - start,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const createMynahUI = (
let mynahUI: MynahUI
// eslint-disable-next-line prefer-const
let connector: Connector
//Store the mapping between messageId and messageUserIntent for amazonq_interactWithMessage telemetry
// Store the mapping between messageId and messageUserIntent for amazonq_interactWithMessage telemetry
const responseMetadata = new Map<string, string[]>()

window.addEventListener('error', (e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export class IamPolicyChecksWebview extends VueWebview {
})
} catch (err: any) {
if (err.status === 2) {
//CLI responds with a status code of 2 when findings are discovered
// CLI responds with a status code of 2 when findings are discovered
const findingsCount = this.handleValidatePolicyCliResponse(err.stdout.toString())
span.record({
findingsCount: findingsCount,
Expand Down Expand Up @@ -652,7 +652,7 @@ export class IamPolicyChecksWebview extends VueWebview {
})
} catch (err: any) {
if (err.status === 2) {
//CLI responds with a status code of 2 when findings are discovered
// CLI responds with a status code of 2 when findings are discovered
const findingsCount = this.handleCustomPolicyChecksCliResponse(err.stdout.toString())
span.record({
findingsCount: findingsCount,
Expand Down Expand Up @@ -752,7 +752,7 @@ export async function renderIamPolicyChecks(context: ExtContext): Promise<VueWeb
const logger: Logger = getLogger()
try {
const client = new AccessAnalyzer({ region: context.regionProvider.defaultRegionId })
//Read from settings to auto-fill some inputs
// Read from settings to auto-fill some inputs
const checkNoNewAccessFilePath: string = vscode.workspace
.getConfiguration()
.get(IamPolicyChecksConstants.CheckNoNewAccessFilePathSetting)!
Expand Down Expand Up @@ -827,7 +827,7 @@ export async function _readCustomChecksFile(input: string): Promise<string> {
}
}

//Check if Cfn and Tf tools are installed
// Check if Cfn and Tf tools are installed
export function arePythonToolsInstalled(): boolean {
const logger: Logger = getLogger()
let cfnToolInstalled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TimeFilterSubmenu extends Prompter<TimeFilterResponse> {

private get recentTimeItems(): DataQuickPickItem<number>[] {
const options: DataQuickPickItem<number>[] = []
//appromixate 31 days as month length (better to overshoot)
// appromixate 31 days as month length (better to overshoot)
options.push({
label: 'All time',
data: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function attachCertificateCommand(node: IotThingNode, promptFun = p

getLogger().debug('Attached certificate %O', cert.certificateId)

//Refresh the Thing node
// Refresh the Thing node
await node.refreshNode()
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/awsService/iot/commands/createCert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Iot } from 'aws-sdk'
import { fs } from '../../../shared'

// eslint-disable-next-line @typescript-eslint/naming-convention
const MODE_RW_R_R = 0o644 //File permission 0644 rw-r--r-- for PEM files.
const MODE_RW_R_R = 0o644 // File permission 0644 rw-r--r-- for PEM files.
// eslint-disable-next-line @typescript-eslint/naming-convention
const PEM_FILE_ENCODING = 'ascii'

Expand Down Expand Up @@ -60,10 +60,10 @@ export async function createCertificateCommand(
getLogger().info(`Downloaded certificate ${certId}`)
void vscode.window.showInformationMessage(localize('AWS.iot.createCert.success', 'Created certificate {0}', certId))

//Save resources
// Save resources
const saveSuccessful = await saveFunc(folderLocation, certId!, certPem, privateKey, publicKey)
if (!saveSuccessful) {
//Delete the certificate if the key pair cannot be saved
// Delete the certificate if the key pair cannot be saved
try {
await node.iot.deleteCertificate({ certificateId: certId! })
} catch (e) {
Expand All @@ -72,7 +72,7 @@ export async function createCertificateCommand(
}
}

//Refresh the Certificate Folder node
// Refresh the Certificate Folder node
await node.refreshNode()
}

Expand Down
Loading

0 comments on commit 90b6fce

Please sign in to comment.