From 46510fcdfd3956cab72ff37c5ba27ac10209575a Mon Sep 17 00:00:00 2001 From: Wenderson Pires Date: Mon, 22 Apr 2024 01:34:23 -0300 Subject: [PATCH] clean up --- lib/actions/loadFilesInfo.js | 1 - lib/actions/transformSchemaToWidget.js | 1 - lib/parsers/extractJSX.js | 56 -------------------------- 3 files changed, 58 deletions(-) diff --git a/lib/actions/loadFilesInfo.js b/lib/actions/loadFilesInfo.js index fe0f890..96676e2 100644 --- a/lib/actions/loadFilesInfo.js +++ b/lib/actions/loadFilesInfo.js @@ -103,7 +103,6 @@ const processFileSchema = (filePath, processOnlyThisFile) => { } } - // let fileContent = fs.readFileSync(filePath, "utf8"); let fileContent = filesContentCache.getFileContent(filePath); // Remove comments from file diff --git a/lib/actions/transformSchemaToWidget.js b/lib/actions/transformSchemaToWidget.js index 6825351..3c1fe01 100644 --- a/lib/actions/transformSchemaToWidget.js +++ b/lib/actions/transformSchemaToWidget.js @@ -392,7 +392,6 @@ const swapComponentsForStatelessFiles = (fileSchemas, fileSchema) => { .replaceAll(MORE_THAN_ONE_SPACE, " "); let childProps = extractPropsFromJSX(htmlElementString); - // TODO: fazer isso dentro do "processChildrenWidget" também const childSpreads = extractSpreadsFromJSX(htmlElementString); // get the children diff --git a/lib/parsers/extractJSX.js b/lib/parsers/extractJSX.js index 37aef64..ad57853 100644 --- a/lib/parsers/extractJSX.js +++ b/lib/parsers/extractJSX.js @@ -1,8 +1,3 @@ -// const babel = require("@babel/core"); -// const presetReact = require("@babel/preset-react"); -// const presetTypeScript = require("@babel/preset-typescript"); // Suporte TypeScript -// const traverse = require("@babel/traverse").default; -// const generate = require("@babel/generator").default; const babel = require("@babel/core"); const presetReact = require("@babel/preset-react"); const presetTypeScript = require("@babel/preset-typescript"); @@ -66,56 +61,5 @@ function extractJSXFromNode(node, jsxList) { extractJSXFromNode(node.alternate, jsxList); } } -// function extractJSX(code) { -// let jsxList = []; - -// const ast = babel.parse(code, { -// presets: [presetReact, presetTypeScript], // Usando presets React e TypeScript -// filename: "input.tsx", // Nome de arquivo fictício necessário para presets -// }); - -// traverse(ast, { -// ReturnStatement(path) { -// let returnArg = path.node.argument; - -// // Manipula retorno de JSX dentro de blocos de código (ex: { return }) -// if (returnArg && returnArg.type === "BlockStatement") { -// returnArg.body.forEach((statement) => { -// if (statement.type === "ReturnStatement") { -// if ( -// statement.argument.type === "JSXElement" || -// statement.argument.type === "JSXFragment" -// ) { -// const jsxCode = generate(statement.argument, { -// concise: true, -// }).code; -// jsxList.push(jsxCode); -// } -// } -// }); -// } -// // Manipula retorno direto de JSX (ex: () => ) -// else if ( -// returnArg && -// (returnArg.type === "JSXElement" || returnArg.type === "JSXFragment") -// ) { -// const jsxCode = generate(returnArg, { concise: true }).code; -// jsxList.push(jsxCode); -// } -// }, -// ArrowFunctionExpression(path) { -// // Diretamente retorna JSX ou fragmento JSX -// if ( -// path.node.body.type === "JSXElement" || -// path.node.body.type === "JSXFragment" -// ) { -// const jsxCode = generate(path.node.body, { concise: true }).code; -// jsxList.push(jsxCode); -// } -// }, -// }); - -// return jsxList; -// } module.exports = extractJSX;