Skip to content

Conversation

@FernandoTheDev
Copy link

Adicionei suporte a ES6, removendo totalmente o CommonJS

Captura de tela de 2025-08-11 13-16-40

@lucaspompeun lucaspompeun self-assigned this Aug 11, 2025
@lucaspompeun
Copy link
Member

@FernandoTheDev por se tratar de um PR bem grande, com muitas alterações e com necessidade de alguns testes, levarei um tempinho para avaliar.

@lucaspompeun lucaspompeun requested a review from Copilot August 12, 2025 00:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR converts the codebase from CommonJS module system to ES6 modules, completely removing module.exports and require() statements in favor of ES6 import and export syntax.

Key changes:

  • Replace all module.exports with ES6 exports (export default, export const, export function, etc.)
  • Replace all require() statements with ES6 import statements
  • Add "type": "module" to package.json to enable ES6 module support

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 22 comments.

Show a summary per file
File Description
package.json Added "type": "module" to enable ES6 module support
index.js Updated to use ES6 imports instead of require
src/egua.js Converted from CommonJS to ES6 module syntax
src/environment.js Converted from CommonJS to ES6 module syntax
src/errors.js Converted from CommonJS to ES6 module syntax
src/expr.js Converted from CommonJS to ES6 module syntax with named exports
src/interpreter.js Converted from CommonJS to ES6 module syntax
src/lexer.js Converted from CommonJS to ES6 module syntax
src/lib/globalLib.js Converted from CommonJS to ES6 module syntax
src/lib/importStdlib.js Converted from CommonJS to ES6 module syntax
src/lib/matematica.js Converted from CommonJS to ES6 module syntax
src/lib/tempo.js Converted from CommonJS to ES6 module syntax
src/lib/textos.js Converted from CommonJS to ES6 module syntax
src/parser.js Converted from CommonJS to ES6 module syntax
src/resolver.js Converted from CommonJS to ES6 module syntax
src/stmt.js Converted from CommonJS to ES6 module syntax with named exports
src/structures/*.js Converted all structure files from CommonJS to ES6 module syntax
src/tokenTypes.js Converted from CommonJS to ES6 module syntax

this.consume(tokenTypes.SEMICOLON, "Esperado ';' após o valor.");

return new Stmt.Escreva(value);
return new _Stmt. Escreva(value);
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space between _Stmt. and Escreva which will cause a syntax error. It should be new _Stmt.Escreva(value).

Suggested change
return new _Stmt. Escreva(value);
return new _Stmt.Escreva(value);

Copilot uses AI. Check for mistakes.
let expr = this.expression();
this.consume(tokenTypes.SEMICOLON, "Esperado ';' após expressão.");
return new Stmt.Expression(expr);
return new _Stmt. Expression(expr);
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space between _Stmt. and Expression which will cause a syntax error. It should be new _Stmt.Expression(expr).

Copilot uses AI. Check for mistakes.
}

return new Stmt.Se(condition, thenBranch, elifBranches, elseBranch);
return new _Stmt. Se(condition, thenBranch, elifBranches, elseBranch);
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space between _Stmt. and Se which will cause a syntax error. It should be new _Stmt.Se(condition, thenBranch, elifBranches, elseBranch).

Suggested change
return new _Stmt. Se(condition, thenBranch, elifBranches, elseBranch);
return new _Stmt.Se(condition, thenBranch, elifBranches, elseBranch);

Copilot uses AI. Check for mistakes.
let body = this.statement();

return new Stmt.Enquanto(condition, body);
return new _Stmt. Enquanto(condition, body);
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space between _Stmt. and Enquanto which will cause a syntax error. It should be new _Stmt.Enquanto(condition, body).

Suggested change
return new _Stmt. Enquanto(condition, body);
return new _Stmt.Enquanto(condition, body);

Copilot uses AI. Check for mistakes.
let body = this.statement();

return new Stmt.Para(initializer, condition, increment, body);
return new _Stmt. Para(initializer, condition, increment, body);
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space between _Stmt. and Para which will cause a syntax error. It should be new _Stmt.Para(initializer, condition, increment, body).

Suggested change
return new _Stmt. Para(initializer, condition, increment, body);
return new _Stmt.Para(initializer, condition, increment, body);

Copilot uses AI. Check for mistakes.
const ReturnExpection = require("../errors.js").ReturnException;
import Callable from "./callable.js";
import Environment from "../environment.js";
import ReturnException from "../errors.js";
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a named import since ReturnException is exported as a named export. It should be import { ReturnException } from "../errors.js".

Suggested change
import ReturnException from "../errors.js";
import { ReturnException } from "../errors.js";

Copilot uses AI. Check for mistakes.
);

let modes = [], count = [], i, number, maxIndex = 0;
let modes = [], count = [], i = 0, number = 0, maxIndex = 0;
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable i is being initialized to 0 here but immediately overwritten in the for loop on line 45. The initialization to 0 is unnecessary.

Suggested change
let modes = [], count = [], i = 0, number = 0, maxIndex = 0;
let modes = [], count = [], i, number = 0, maxIndex = 0;

Copilot uses AI. Check for mistakes.
const r1 = (-1 * b + Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a);
const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a);
// const r1 = (-1 * b + Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a);
// const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a);
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These commented-out variable declarations should be removed if they are not needed, as they add clutter to the code.

Suggested change
// const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a);

Copilot uses AI. Check for mistakes.
const isDict = obj => obj.constructor === Object;

console.log("Exported: ", exported)
console.log("Dict: ", isDict(exported))
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statements should be removed from production code.

Suggested change
console.log("Dict: ", isDict(exported))

Copilot uses AI. Check for mistakes.

console.log("Exported: ", exported)
console.log("Dict: ", isDict(exported))

Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statements should be removed from production code.

Suggested change

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants