Skip to content
Closed
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/soft-bottles-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": minor
---

Bumps jscodeshift to v17.3.0
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"test": "node --import tsx --test src/**/*.spec.ts"
},
"dependencies": {
"jscodeshift": "17.1.1"
"jscodeshift": "17.3.0"
},
"devDependencies": {
"@biomejs/biome": "1.9.0",
"@changesets/cli": "^2.27.1",
"@tsconfig/node18": "^18.2.4",
"@types/jscodeshift": "^0.12.0",
"@types/jscodeshift": "^17.3.0",
"@types/node": "^16.18.101",
"aws-sdk": "2.1692.0",
"tsx": "^4.7.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getImportSpecifiers = (
const importSpecifiers = new Set<ImportSpecifierType>();

getImportEqualsDeclarations(j, source, path).forEach((importEqualsDeclaration) => {
importSpecifiers.add({ localName: importEqualsDeclaration.value.id.name });
importSpecifiers.add({ localName: importEqualsDeclaration.value.id.name as string });
});

return Array.from(importSpecifiers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const isAnotherSpecifier = (j: JSCodeshift, source: Collection<unknown>, localNa

export const removeImportEquals = (j: JSCodeshift, source: Collection<unknown>) =>
getImportEqualsDeclarations(j, source).forEach((importEqualsDeclaration) => {
const localName = importEqualsDeclaration.value.id.name;
const localName = importEqualsDeclaration.value.id.name as string;
const identifiers = source.find(j.Identifier, { name: localName });

// Either the identifier is the only occurence on the page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ export const getImportSpecifiers = (
for (const specifier of specifiers) {
switch (specifier.type) {
case "ImportSpecifier": {
const importedName = specifier.imported.name;
const importedName = specifier.imported.name as string;
importSpecifiers.add({
importedName,
localName: specifier.local?.name || importedName,
localName: (specifier.local?.name as string) || importedName,
});
break;
}
case "ImportNamespaceSpecifier":
case "ImportDefaultSpecifier": {
if (specifier.local) {
importSpecifiers.add({ localName: specifier.local.name });
importSpecifiers.add({ localName: specifier.local.name as string });
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const removeImport = (j: JSCodeshift, source: Collection<unknown>) =>
getImportDeclarations(j, source).forEach((importDeclaration) => {
importDeclaration.value.specifiers = (importDeclaration.value.specifiers || []).filter(
(specifier) => {
const localName = specifier.local?.name;
const localName = specifier.local?.name as string;
if (!localName) {
return true;
}
Expand Down
11 changes: 8 additions & 3 deletions src/transforms/v2-to-v3/modules/importSpecifierCompareFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ export const importSpecifierCompareFn = (
specifier2: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier
) => {
if (specifier1.type === "ImportSpecifier" && specifier2.type === "ImportSpecifier") {
return specifier1.imported.name.localeCompare(specifier2.imported.name);
const specifier1ImportedName = specifier1.imported.name as string;
const specifier2ImportedName = specifier2.imported.name as string;
return specifier1ImportedName.localeCompare(specifier2ImportedName);
}

const specifier1LocalName = specifier1.local?.name as string;
const specifier2LocalName = specifier2.local?.name as string;

if (
specifier1.type === "ImportDefaultSpecifier" &&
specifier2.type === "ImportDefaultSpecifier"
) {
if (specifier1.local && specifier2.local)
return specifier1.local.name.localeCompare(specifier2.local.name);
return specifier1LocalName.localeCompare(specifier2LocalName);
return 0;
}

Expand All @@ -26,7 +31,7 @@ export const importSpecifierCompareFn = (
specifier2.type === "ImportNamespaceSpecifier"
) {
if (specifier1.local && specifier2.local)
return specifier1.local.name.localeCompare(specifier2.local.name);
return specifier1LocalName.localeCompare(specifier2LocalName);
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
ObjectProperty,
Property,
PropertyPattern,
RestElement,
RestProperty,
SpreadProperty,
SpreadPropertyPattern,
Expand All @@ -13,6 +14,7 @@ export type ObjectPatternProperty =
| SpreadPropertyPattern
| SpreadProperty
| ObjectProperty
| RestElement
| RestProperty;

export const objectPatternPropertyCompareFn = (
Expand All @@ -26,7 +28,9 @@ export const objectPatternPropertyCompareFn = (
return 0;
}
if (property1.key.type === "Identifier" && property2.key.type === "Identifier") {
return property1.key.name.localeCompare(property2.key.name);
const property1KeyName = property1.key.name as string;
const property2KeyName = property2.key.name as string;
return property1KeyName.localeCompare(property2KeyName);
}
return 0;
};
49 changes: 14 additions & 35 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1083,13 +1083,13 @@ __metadata:
languageName: node
linkType: hard

"@types/jscodeshift@npm:^0.12.0":
version: 0.12.0
resolution: "@types/jscodeshift@npm:0.12.0"
"@types/jscodeshift@npm:^17.3.0":
version: 17.3.0
resolution: "@types/jscodeshift@npm:17.3.0"
dependencies:
ast-types: "npm:^0.14.1"
recast: "npm:^0.20.3"
checksum: 10c0/18dea1a12f47daa35063c872a255a7239125187b172ce66639c326bd4b6a500fc8b44a98ec3a8e3fc502786658874a6b35850ac9f4effd9b9aacd1602b033feb
ast-types: "npm:^0.16.1"
recast: "npm:^0.23.11"
checksum: 10c0/56b889b290f12322b43d74c7434b69cef3e1ca8444e37891e08585f716b1c23f44596f650fb92220a8c6e5776d3dbc7d8ece67e950b6f9e733eee8e712128c73
languageName: node
linkType: hard

Expand Down Expand Up @@ -1174,15 +1174,6 @@ __metadata:
languageName: node
linkType: hard

"ast-types@npm:0.14.2, ast-types@npm:^0.14.1":
version: 0.14.2
resolution: "ast-types@npm:0.14.2"
dependencies:
tslib: "npm:^2.0.1"
checksum: 10c0/5d66d89b6c07fe092087454b6042dbaf81f2882b176db93861e2b986aafe0bce49e1f1ff59aac775d451c1426ad1e967d250e9e3548f5166ea8a3475e66c169d
languageName: node
linkType: hard

"ast-types@npm:^0.16.1":
version: 0.16.1
resolution: "ast-types@npm:0.16.1"
Expand All @@ -1208,10 +1199,10 @@ __metadata:
"@biomejs/biome": "npm:1.9.0"
"@changesets/cli": "npm:^2.27.1"
"@tsconfig/node18": "npm:^18.2.4"
"@types/jscodeshift": "npm:^0.12.0"
"@types/jscodeshift": "npm:^17.3.0"
"@types/node": "npm:^16.18.101"
aws-sdk: "npm:2.1692.0"
jscodeshift: "npm:17.1.1"
jscodeshift: "npm:17.3.0"
tsx: "npm:^4.7.1"
typescript: "npm:~5.8.3"
bin:
Expand Down Expand Up @@ -2271,9 +2262,9 @@ __metadata:
languageName: node
linkType: hard

"jscodeshift@npm:17.1.1":
version: 17.1.1
resolution: "jscodeshift@npm:17.1.1"
"jscodeshift@npm:17.3.0":
version: 17.3.0
resolution: "jscodeshift@npm:17.3.0"
dependencies:
"@babel/core": "npm:^7.24.7"
"@babel/parser": "npm:^7.24.7"
Expand All @@ -2290,7 +2281,7 @@ __metadata:
micromatch: "npm:^4.0.7"
neo-async: "npm:^2.5.0"
picocolors: "npm:^1.0.1"
recast: "npm:^0.23.9"
recast: "npm:^0.23.11"
tmp: "npm:^0.2.3"
write-file-atomic: "npm:^5.0.1"
peerDependencies:
Expand All @@ -2300,7 +2291,7 @@ __metadata:
optional: true
bin:
jscodeshift: bin/jscodeshift.js
checksum: 10c0/bd41e86e6cb6cd7dedb9a5b34740d1a44356e77c22fe70bd6ea20beb5bb4075c8bb2a372ba3d20a798931d678576895ec026f47b368677e0d2a29c5b5e6307bd
checksum: 10c0/366e3c8ec52597a00919c6eb37007b6bcde0037722b89bda0a4416aec36e34717a7c46d10b3e637ac0a2cf91b986e868063fd1e99a943699ac292f7aef78e3ba
languageName: node
linkType: hard

Expand Down Expand Up @@ -2832,19 +2823,7 @@ __metadata:
languageName: node
linkType: hard

"recast@npm:^0.20.3":
version: 0.20.5
resolution: "recast@npm:0.20.5"
dependencies:
ast-types: "npm:0.14.2"
esprima: "npm:~4.0.0"
source-map: "npm:~0.6.1"
tslib: "npm:^2.0.1"
checksum: 10c0/7810216ff36c7376eddd66d3ce6b2df421305fdc983f2122711837911712177d52d804419655e1f29d4bb93016c178cffe442af410bdcf726050ca19af6fed32
languageName: node
linkType: hard

"recast@npm:^0.23.9":
"recast@npm:^0.23.11":
version: 0.23.11
resolution: "recast@npm:0.23.11"
dependencies:
Expand Down