diff --git a/.changeset/happy-seahorses-buy.md b/.changeset/happy-seahorses-buy.md new file mode 100644 index 000000000..a51cab73f --- /dev/null +++ b/.changeset/happy-seahorses-buy.md @@ -0,0 +1,5 @@ +--- +"aws-sdk-js-codemod": patch +--- + +Check for raw string in extra.raw when searching for quotes diff --git a/src/transforms/v2-to-v3/__fixtures__/misc/single-quote.require.input.js b/src/transforms/v2-to-v3/__fixtures__/misc/single-quote.require.input.js new file mode 100644 index 000000000..12ab19858 --- /dev/null +++ b/src/transforms/v2-to-v3/__fixtures__/misc/single-quote.require.input.js @@ -0,0 +1,3 @@ +const AWS = require('aws-sdk'); + +const client = new AWS.DynamoDB(); \ No newline at end of file diff --git a/src/transforms/v2-to-v3/__fixtures__/misc/single-quote.require.output.js b/src/transforms/v2-to-v3/__fixtures__/misc/single-quote.require.output.js new file mode 100644 index 000000000..790a47f48 --- /dev/null +++ b/src/transforms/v2-to-v3/__fixtures__/misc/single-quote.require.output.js @@ -0,0 +1,3 @@ +const { DynamoDB } = require('@aws-sdk/client-dynamodb'); + +const client = new DynamoDB(); \ No newline at end of file diff --git a/src/transforms/v2-to-v3/utils/getMostUsedStringLiteralQuote.ts b/src/transforms/v2-to-v3/utils/getMostUsedStringLiteralQuote.ts index 696792cd5..c8d136fed 100644 --- a/src/transforms/v2-to-v3/utils/getMostUsedStringLiteralQuote.ts +++ b/src/transforms/v2-to-v3/utils/getMostUsedStringLiteralQuote.ts @@ -21,7 +21,7 @@ export const getMostUsedStringLiteralQuote = ( if (typeof value === "string") { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore Property 'raw' does not exist on type 'Literal'. - const rawValue = path.node.raw || ""; + const rawValue = path.node.raw || path.node.extra?.raw || ""; if (rawValue.startsWith("'")) { quoteCount[StringLiteralQuoteType.SINGLE]++; } else if (rawValue.startsWith('"')) {