Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function toggleOverrideSharedProps(code: string, sharedProps: string[]) {
let result: string = '';
try {
const ast = parse(code);
traverse(ast, {
ArrowFunctionExpression(path) {
if (result !== '') return;
if (path.node.params.length !== 1) return;
const firstParam: any = path.node.params[0];
let newParams: string[] = [];
if (firstParam.type === 'ObjectPattern') {
const properties = firstParam.properties;
newParams = properties.map((prop: any) => prop.key.name);
}
const shoudlWeAddSharedProps = newParams.every(
name => !sharedProps.includes(name),
);
if (shoudlWeAddSharedProps) {