Skip to content

Commit

Permalink
feat: converted codemods to use tsx parser for greater reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Sep 19, 2024
1 parent aad042b commit 376d5c3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/codemods/src/__test__/fixtures/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetchMock from 'fetch-mock';
function helper (res: number): {
function helper (res: number):void {
fetchMock.mock("blah", res)
};
2 changes: 1 addition & 1 deletion packages/codemods/src/__test__/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function expectCodemodResult(src, expected) {
describe('integration', () => {

it('can operate on typescript', async () => {
const { stdout, stderr } = await exec('jscodeshift -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__test__/fixtures/typescript.ts')
const { stdout, stderr } = await exec('jscodeshift --parser ts -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__test__/fixtures/typescript.ts')
console.log({ stdout, stderr })
// expectCodemodResult(
// `import fetchMock from 'fetch-mock';
Expand Down
4 changes: 2 additions & 2 deletions packages/codemods/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const j = require( 'jscodeshift');
const j = require( 'jscodeshift').withParser('tsx');
const { simpleOptions } = require( './codemods/options.js');
const { simpleMethods } = require( './codemods/methods.js');

Expand Down Expand Up @@ -40,7 +40,7 @@ function codemod(source, variableName) {
return root.toSource();
}

function transformer(file, api) {
function transformer(file) {
let modifiedSource = codemod(file.source);
if (process.env.FM_VARIABLES) {
const extraVariables = process.env.FM_VARIABLES.split(',');
Expand Down

0 comments on commit 376d5c3

Please sign in to comment.