-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use formatting conventions of tabs or spaces from input code (#710)
- Loading branch information
Showing
6 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"aws-sdk-js-codemod": patch | ||
--- | ||
|
||
Use formatting conventions of tabs or spaces from input code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import AWS from "aws-sdk"; | ||
|
||
// Client creation with tabs instead of spaces for indentation. | ||
const client = new AWS.DynamoDB({ | ||
accessKeyId: "KEY", | ||
secretAccessKey: "SECRET" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { DynamoDB } from "@aws-sdk/client-dynamodb"; | ||
|
||
// Client creation with tabs instead of spaces for indentation. | ||
const client = new DynamoDB({ | ||
credentials: { | ||
accessKeyId: "KEY", | ||
secretAccessKey: "SECRET" | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/transforms/v2-to-v3/utils/getMostUsedIndentationType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export enum IndentationType { | ||
TAB = "tab", | ||
SPACE = "space", | ||
} | ||
|
||
export const getMostUsedIndentationType = (source: string) => { | ||
const tabCount = (source.match(/\t/g) || []).length; | ||
const spaceCount = (source.match(/ {2}/g) || []).length; | ||
console.log({ tabCount, spaceCount }); | ||
|
||
if (tabCount > spaceCount) { | ||
return IndentationType.TAB; | ||
} | ||
return IndentationType.SPACE; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./getClientDeepImportPath"; | ||
export * from "./getClientNewExpression"; | ||
export * from "./getMostUsedStringLiteralQuote"; | ||
export * from "./getMostUsedIndentationType"; | ||
export * from "./isTypeScriptFile"; |