Skip to content

Commit c8343a7

Browse files
authored
Enable all supported extensions by default in config (#770)
1 parent f29a836 commit c8343a7

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

.changeset/neat-peaches-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Enable all supported extensions by default in config

src/cli.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2525
// @ts-nocheck
2626
import path from "path";
27-
import { DEFAULT_EXTENSIONS } from "@babel/core";
2827
import Runner from "jscodeshift/dist/Runner";
2928

3029
import {
@@ -41,16 +40,6 @@ if (args[2] === "--help" || args[2] === "-h") {
4140
process.stdout.write(getHelpParagraph(transforms));
4241
}
4342

44-
// Refs: https://github.com/facebook/jscodeshift/issues/582
45-
if (!args.some((arg) => arg.startsWith("--extensions"))) {
46-
// Explicitly add all extensions as default to avoid bug in jscodeshift.
47-
// Refs: https://github.com/facebook/jscodeshift/blob/51da1a5c4ba3707adb84416663634d4fc3141cbb/src/Worker.js#L80
48-
const babelExtensions = DEFAULT_EXTENSIONS.map((ext) =>
49-
ext.startsWith(".") ? ext.substring(1) : ext
50-
);
51-
args.push(`--extensions=${[...babelExtensions, "ts", "tsx"].join(",")}`);
52-
}
53-
5443
const disclaimerLines = [
5544
`╔════════════════════════════════════════════════════════╗`,
5645
`║ Please review the code change thoroughly for required ║`,

src/utils/getJsCodeshiftParser.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { readFileSync } from "fs";
88
import { dirname, join } from "path";
9+
import { DEFAULT_EXTENSIONS } from "@babel/core";
910
import argsParser from "jscodeshift/dist/argsParser";
1011

1112
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -76,7 +77,16 @@ export const getJsCodeshiftParser = () =>
7677
},
7778
extensions: {
7879
display_index: 3,
79-
default: "js",
80+
// Explicitly add all extensions as default to avoid bug in jscodeshift.
81+
// Refs: https://github.com/facebook/jscodeshift/issues/582
82+
// Source code: https://github.com/facebook/jscodeshift/blob/51da1a5c4ba3707adb84416663634d4fc3141cbb/src/Worker.js#L80
83+
default: [
84+
...DEFAULT_EXTENSIONS.map((ext) => (ext.startsWith(".") ? ext.substring(1) : ext)),
85+
"ts",
86+
"tsx",
87+
]
88+
.sort()
89+
.join(","),
8090
help: "transform files with these file extensions (comma separated list)",
8191
metavar: "EXT",
8292
},

0 commit comments

Comments
 (0)