From b9754101ec3bdbae286920088446315496649091 Mon Sep 17 00:00:00 2001 From: Akira Hayashi Date: Sat, 1 Jun 2024 13:42:27 +0900 Subject: [PATCH] Lint codes --- readme.md | 12 +++++++++++- src/config.ts | 1 - src/printers/fancy.ts | 2 +- src/printers/slack.ts | 2 +- src/printers/text.test.ts | 1 - 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 29d38f8..fa8d601 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,5 @@ ## aws-cost-cli + > CLI tool to perform cost analysis on your AWS account with Slack integration ![](.github/images/aws-cost.gif) @@ -13,7 +14,7 @@ npm install -g aws-cost-cli ## Usage -For the simple usage, just run the command without any options. +For the simple usage, just run the command without any options. ``` aws-cost @@ -63,36 +64,43 @@ aws-cost To configure the credentials using aws-cli, have a look at the [aws-cli docs](https://github.com/aws/aws-cli#configuration) for more information. ## Detailed Breakdown + > The default usage is to get the cost breakdown by service ```bash aws-cost ``` + You will get the following output ![Default Usage](./.github/images/default-demo.gif) ## Total Costs + > You can also get the summary of the cost without the service breakdown ```bash aws-cost --summary ``` + You will get the following output ![Summary Usage](./.github/images/summary-demo.gif) ## Plain Text + > You can also get the output as plain text ```bash aws-cost --text ``` + You will get the following output in response ![Text Usage](./.github/images/text-usage.png) ## JSON Output + > You can also get the output as JSON ```bash @@ -151,6 +159,7 @@ aws-cost --json } } ``` + ## Slack Integration @@ -191,4 +200,5 @@ Regarding the credentials, you need to have the following permissions in order t Also, please note that this tool uses AWS Cost Explorer under the hood which [costs $0.01 per request](https://aws.amazon.com/aws-cost-management/aws-cost-explorer/pricing/). ## License + MIT © [Kamran Ahmed](https://twitter.com/kamranahmedse) diff --git a/src/config.ts b/src/config.ts index 44af72b..0f040be 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,3 @@ -import fs from 'node:fs'; import { loadSharedConfigFiles } from '@aws-sdk/shared-ini-file-loader'; import chalk from 'chalk'; import { printFatalError } from './logger'; diff --git a/src/printers/fancy.ts b/src/printers/fancy.ts index 8094c8d..df7925f 100644 --- a/src/printers/fancy.ts +++ b/src/printers/fancy.ts @@ -57,7 +57,7 @@ export function printFancy( `${serviceHeader} ${lastMonthHeader} ${thisMonthHeader} ${last7DaysHeader} ${yesterdayHeader}`, ); - for (let service of sortedServiceNames) { + for (const service of sortedServiceNames) { const serviceLabel = chalk.cyan(service.padStart(maxServiceLength)); const lastMonthTotal = chalk.green( `$${serviceCosts.lastMonth[service].toFixed(2)}`.padEnd(headerPadLength), diff --git a/src/printers/slack.ts b/src/printers/slack.ts index 3b76c34..ec88ba6 100644 --- a/src/printers/slack.ts +++ b/src/printers/slack.ts @@ -33,7 +33,7 @@ export async function notifySlack( const totals = costs.totals; const serviceCosts = costs.totalsByService; - let serviceCostsYesterday = []; + const serviceCostsYesterday = []; Object.keys(serviceCosts.yesterday).forEach((service) => { serviceCosts.yesterday[service].toFixed(2); serviceCostsYesterday.push( diff --git a/src/printers/text.test.ts b/src/printers/text.test.ts index 314a230..dc96bc0 100644 --- a/src/printers/text.test.ts +++ b/src/printers/text.test.ts @@ -1,5 +1,4 @@ import { TotalCosts } from '../cost'; -import { hideSpinner } from '../logger'; import { printPlainSummary } from './text'; describe('printPlainSummary', () => {