Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for raw string in extra.raw when searching for quotes #721

Merged
merged 3 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-seahorses-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Check for raw string in extra.raw when searching for quotes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const AWS = require('aws-sdk');

const client = new AWS.DynamoDB();
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { DynamoDB } = require('@aws-sdk/client-dynamodb');

const client = new DynamoDB();
Original file line number Diff line number Diff line change
Expand Up @@ -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('"')) {
Expand Down