Skip to content

Commit

Permalink
fixup! Fix(codemods): Fix bug with extra parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelklibani committed Nov 15, 2024
1 parent 76e0978 commit c51d9a0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/codemods/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { errorMessage, infoMessage, logMessage } from './message';
import { _dirname } from './path';
import { removeCircleBrackets } from './removeCircleBrackets';
import { removeParentheses } from './removeParentheses';

export { _dirname, errorMessage, infoMessage, logMessage, removeCircleBrackets };
export { _dirname, errorMessage, infoMessage, logMessage, removeParentheses };
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const REG_RETURN = /return\s+\((\s+)\(<([^\s>]+)/g;

export const removeCircleBrackets = (string: string): string => {
export const removeParentheses = (string: string): string => {
const matches: IterableIterator<RegExpMatchArray> = string.matchAll(REG_RETURN);
let result = '';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API, FileInfo } from 'jscodeshift';
import { removeCircleBrackets } from '../../../helpers';
import { removeParentheses } from '../../../helpers';

const transform = (fileInfo: FileInfo, api: API) => {
const j = api.jscodeshift;
Expand Down Expand Up @@ -45,7 +45,7 @@ const transform = (fileInfo: FileInfo, api: API) => {
}
}

return removeCircleBrackets(root.toSource());
return removeParentheses(root.toSource());
};

export default transform;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API, FileInfo } from 'jscodeshift';
import { removeCircleBrackets } from '../../../helpers';
import { removeParentheses } from '../../../helpers';

const transform = (fileInfo: FileInfo, api: API) => {
const j = api.jscodeshift;
Expand Down Expand Up @@ -45,7 +45,7 @@ const transform = (fileInfo: FileInfo, api: API) => {
}
}

return removeCircleBrackets(root.toSource());
return removeParentheses(root.toSource());
};

export default transform;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API, FileInfo } from 'jscodeshift';
import { removeCircleBrackets } from '../../../helpers';
import { removeParentheses } from '../../../helpers';

const transform = (fileInfo: FileInfo, api: API) => {
const j = api.jscodeshift;
Expand Down Expand Up @@ -44,7 +44,7 @@ const transform = (fileInfo: FileInfo, api: API) => {
}
}

return removeCircleBrackets(root.toSource());
return removeParentheses(root.toSource());
};

export default transform;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ImportDeclaration,
JSXOpeningElement,
} from 'jscodeshift';
import { removeCircleBrackets } from '../../../helpers';
import { removeParentheses } from '../../../helpers';

const transform = (fileInfo: FileInfo, api: API): string => {
const j: JSCodeshift = api.jscodeshift;
Expand Down Expand Up @@ -62,7 +62,7 @@ const transform = (fileInfo: FileInfo, api: API): string => {
});
}

return removeCircleBrackets(root.toSource());
return removeParentheses(root.toSource());
};

export default transform;

0 comments on commit c51d9a0

Please sign in to comment.