build: update npm install command to use --legacy-peer-deps

This change modifies the build scripts to use --legacy-peer-deps flag when installing npm dependencies to resolve potential peer dependency conflicts during the build process. The change is applied to both bash (build.sh) and batch (build.bat) build scripts.
This commit is contained in:
Luiz Costa
2025-11-18 10:23:55 -03:00
parent 20129a1ac7
commit ac4f232e5e
787 changed files with 82341 additions and 121690 deletions
-17
View File
@@ -1,17 +0,0 @@
/**
* @fileoverview Assertion utilities.
* @author Nicholas C. Zakas
*/
/**
* Throws an error if the given condition is not truthy.
* @param {boolean} condition The condition to check.
* @param {string} message The message to include with the error.
* @returns {void}
* @throws {Error} When the condition is not truthy.
*/
export function assert(condition, message = "Assertion failed.") {
if (!condition) {
throw new Error(message);
}
}
+5 -3
View File
@@ -45,8 +45,9 @@
* The main interface is the {@link analyze} function.
* @module escope
*/
/* eslint no-underscore-dangle: ["error", { "allow": ["__currentScope"] }] */
import { assert } from "./assert.js";
import assert from "assert";
import ScopeManager from "./scope-manager.js";
import Referencer from "./referencer.js";
@@ -62,6 +63,7 @@ import eslintScopeVersion from "./version.js";
function defaultOptions() {
return {
optimistic: false,
directive: false,
nodejsScope: false,
impliedStrict: false,
sourceType: "script", // one of ['script', 'module', 'commonjs']
@@ -89,7 +91,7 @@ function updateDeeply(target, override) {
}
for (const key in override) {
if (Object.hasOwn(override, key)) {
if (Object.prototype.hasOwnProperty.call(override, key)) {
const val = override[key];
if (isHashObject(val)) {
@@ -113,6 +115,7 @@ function updateDeeply(target, override) {
* @param {espree.Tree} tree Abstract Syntax Tree
* @param {Object} providedOptions Options that tailor the scope analysis
* @param {boolean} [providedOptions.optimistic=false] the optimistic flag
* @param {boolean} [providedOptions.directive=false] the directive flag
* @param {boolean} [providedOptions.ignoreEval=false] whether to check 'eval()' calls
* @param {boolean} [providedOptions.nodejsScope=false] whether the whole
* script is executed under node.js environment. When enabled, escope adds
@@ -121,7 +124,6 @@ function updateDeeply(target, override) {
* (if ecmaVersion >= 5).
* @param {string} [providedOptions.sourceType='script'] the source type of the script. one of 'script', 'module', and 'commonjs'
* @param {number} [providedOptions.ecmaVersion=5] which ECMAScript version is considered
* @param {boolean} [providedOptions.jsx=false] support JSX references
* @param {Object} [providedOptions.childVisitorKeys=null] Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
* @param {string} [providedOptions.fallback='iteration'] A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
* @returns {ScopeManager} ScopeManager
+4 -5
View File
@@ -22,6 +22,8 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* eslint-disable no-undefined */
import estraverse from "estraverse";
import esrecurse from "esrecurse";
@@ -33,12 +35,9 @@ const { Syntax } = estraverse;
* @returns {any} Last elment
*/
function getLast(xs) {
return xs.at(-1) || null;
return xs[xs.length - 1] || null;
}
/**
* Visitor for destructuring patterns.
*/
class PatternVisitor extends esrecurse.Visitor {
static isPattern(node) {
const nodeType = node.type;
@@ -67,7 +66,7 @@ class PatternVisitor extends esrecurse.Visitor {
this.callback(pattern, {
topLevel: pattern === this.rootPattern,
rest: lastRestElement !== null && lastRestElement !== void 0 && lastRestElement.argument === pattern,
rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern,
assignments: this.assignments
});
}
+13 -67
View File
@@ -22,13 +22,16 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-undefined */
import estraverse from "estraverse";
import esrecurse from "esrecurse";
import Reference from "./reference.js";
import Variable from "./variable.js";
import PatternVisitor from "./pattern-visitor.js";
import { Definition, ParameterDefinition } from "./definition.js";
import { assert } from "./assert.js";
import assert from "assert";
const { Syntax } = estraverse;
@@ -48,7 +51,7 @@ function traverseIdentifierInPattern(options, rootPattern, referencer, callback)
visitor.visit(rootPattern);
// Process the right hand nodes recursively.
if (referencer !== null && referencer !== void 0) {
if (referencer !== null && referencer !== undefined) {
visitor.rightHandNodes.forEach(referencer.visit, referencer);
}
}
@@ -59,9 +62,6 @@ function traverseIdentifierInPattern(options, rootPattern, referencer, callback)
// FIXME: Now, we don't create module environment, because the context is
// implementation dependent.
/**
* Visitor for import specifiers.
*/
class Importer extends esrecurse.Visitor {
constructor(declaration, referencer) {
super(null, referencer.options);
@@ -108,9 +108,7 @@ class Importer extends esrecurse.Visitor {
}
}
/**
* Referencing variables and creating bindings.
*/
// Referencing variables and creating bindings.
class Referencer extends esrecurse.Visitor {
constructor(options, scopeManager) {
super(null, options);
@@ -274,6 +272,8 @@ class Referencer extends esrecurse.Visitor {
));
}
this.visit(node.superClass);
this.scopeManager.__nestClassScope(node);
if (node.id) {
@@ -284,8 +284,6 @@ class Referencer extends esrecurse.Visitor {
node
));
}
this.visit(node.superClass);
this.visit(node.body);
this.close(node);
@@ -395,7 +393,7 @@ class Referencer extends esrecurse.Visitor {
this.currentScope().__define(pattern,
new Definition(
Variable.CatchClause,
pattern,
node.param,
node,
null,
null,
@@ -434,7 +432,7 @@ class Referencer extends esrecurse.Visitor {
this.currentScope().__referencing(node);
}
// eslint-disable-next-line class-methods-use-this -- Desired as instance method
// eslint-disable-next-line class-methods-use-this
PrivateIdentifier() {
// Do nothing.
@@ -484,9 +482,9 @@ class Referencer extends esrecurse.Visitor {
this.visitProperty(node);
}
BreakStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
BreakStatement() {} // eslint-disable-line class-methods-use-this
ContinueStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
ContinueStatement() {} // eslint-disable-line class-methods-use-this
LabeledStatement(node) {
this.visit(node.body);
@@ -645,62 +643,10 @@ class Referencer extends esrecurse.Visitor {
this.visit(local);
}
MetaProperty() { // eslint-disable-line class-methods-use-this -- Desired as instance method
MetaProperty() { // eslint-disable-line class-methods-use-this
// do nothing.
}
JSXIdentifier(node) {
// Special case: "this" should not count as a reference
if (this.scopeManager.__isJSXEnabled() && node.name !== "this") {
this.currentScope().__referencing(node);
}
}
JSXMemberExpression(node) {
this.visit(node.object);
}
JSXElement(node) {
if (this.scopeManager.__isJSXEnabled()) {
this.visit(node.openingElement);
node.children.forEach(this.visit, this);
} else {
this.visitChildren(node);
}
}
JSXOpeningElement(node) {
if (this.scopeManager.__isJSXEnabled()) {
const nameNode = node.name;
const isComponentName = nameNode.type === "JSXIdentifier" && nameNode.name[0].toUpperCase() === nameNode.name[0];
const isComponent = isComponentName || nameNode.type === "JSXMemberExpression";
// we only want to visit JSXIdentifier nodes if they are capitalized
if (isComponent) {
this.visit(nameNode);
}
}
node.attributes.forEach(this.visit, this);
}
JSXAttribute(node) {
if (node.value) {
this.visit(node.value);
}
}
JSXExpressionContainer(node) {
this.visit(node.expression);
}
JSXNamespacedName(node) {
this.visit(node.namespace);
this.visit(node.name);
}
}
export default Referencer;
+9 -7
View File
@@ -22,6 +22,8 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* eslint-disable no-underscore-dangle */
import {
BlockScope,
CatchScope,
@@ -36,7 +38,7 @@ import {
SwitchScope,
WithScope
} from "./scope.js";
import { assert } from "./assert.js";
import assert from "assert";
/**
* @constructor ScopeManager
@@ -51,6 +53,10 @@ class ScopeManager {
this.__declaredVariables = new WeakMap();
}
__useDirective() {
return this.__options.directive;
}
__isOptimistic() {
return this.__options.optimistic;
}
@@ -59,10 +65,6 @@ class ScopeManager {
return this.__options.ignoreEval;
}
__isJSXEnabled() {
return this.__options.jsx === true;
}
isGlobalReturn() {
return this.__options.nodejsScope || this.__options.sourceType === "commonjs";
}
@@ -182,9 +184,9 @@ class ScopeManager {
return null;
}
attach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
attach() { } // eslint-disable-line class-methods-use-this
detach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
detach() { } // eslint-disable-line class-methods-use-this
__nestScope(scope) {
if (scope instanceof GlobalScope) {
+45 -66
View File
@@ -22,12 +22,15 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-undefined */
import estraverse from "estraverse";
import Reference from "./reference.js";
import Variable from "./variable.js";
import { Definition } from "./definition.js";
import { assert } from "./assert.js";
import assert from "assert";
const { Syntax } = estraverse;
@@ -36,9 +39,10 @@ const { Syntax } = estraverse;
* @param {Scope} scope scope
* @param {Block} block block
* @param {boolean} isMethodDefinition is method definition
* @param {boolean} useDirective use directive
* @returns {boolean} is strict scope
*/
function isStrictScope(scope, block, isMethodDefinition) {
function isStrictScope(scope, block, isMethodDefinition, useDirective) {
let body;
// When upper scope is exists and strict, inner scope is also strict.
@@ -78,29 +82,41 @@ function isStrictScope(scope, block, isMethodDefinition) {
return false;
}
// Search for a 'use strict' directive.
for (let i = 0, iz = body.body.length; i < iz; ++i) {
const stmt = body.body[i];
// Search 'use strict' directive.
if (useDirective) {
for (let i = 0, iz = body.body.length; i < iz; ++i) {
const stmt = body.body[i];
/*
* Check if the current statement is a directive.
* If it isn't, then we're past the directive prologue
* so stop the search because directives cannot
* appear after this point.
*
* Some parsers set `directive:null` on non-directive
* statements, so the `typeof` check is safer than
* checking for property existence.
*/
if (typeof stmt.directive !== "string") {
break;
if (stmt.type !== Syntax.DirectiveStatement) {
break;
}
if (stmt.raw === "\"use strict\"" || stmt.raw === "'use strict'") {
return true;
}
}
} else {
for (let i = 0, iz = body.body.length; i < iz; ++i) {
const stmt = body.body[i];
if (stmt.directive === "use strict") {
return true;
if (stmt.type !== Syntax.ExpressionStatement) {
break;
}
const expr = stmt.expression;
if (expr.type !== Syntax.Literal || typeof expr.value !== "string") {
break;
}
if (expr.raw !== null && expr.raw !== undefined) {
if (expr.raw === "\"use strict\"" || expr.raw === "'use strict'") {
return true;
}
} else {
if (expr.value === "use strict") {
return true;
}
}
}
}
return false;
}
@@ -157,8 +173,7 @@ class Scope {
/**
* The tainted variables of this scope, as <code>{ Variable.name :
* boolean }</code>.
* @member {Map} Scope#taints
*/
* @member {Map} Scope#taints */
this.taints = new Map();
/**
@@ -249,7 +264,7 @@ class Scope {
* @member {boolean} Scope#isStrict
*/
this.isStrict = scopeManager.isStrictModeSupported()
? isStrictScope(this, block, isMethodDefinition)
? isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective())
: false;
/**
@@ -337,7 +352,7 @@ class Scope {
// To override by function scopes.
// References in default parameters isn't resolved to variables which are in their function body.
__isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars -- Desired as instance method with signature
__isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars
return true;
}
@@ -371,17 +386,17 @@ class Scope {
}
__addDeclaredVariablesOfNode(variable, node) {
if (node === null || node === void 0) {
if (node === null || node === undefined) {
return;
}
let variables = this.__declaredVariables.get(node);
if (variables === null || variables === void 0) {
if (variables === null || variables === undefined) {
variables = [];
this.__declaredVariables.set(node, variables);
}
if (!variables.includes(variable)) {
if (variables.indexOf(variable) === -1) {
variables.push(variable);
}
}
@@ -421,7 +436,7 @@ class Scope {
__referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
// because Array element may be null
if (!node || (node.type !== Syntax.Identifier && node.type !== "JSXIdentifier")) {
if (!node || node.type !== Syntax.Identifier) {
return;
}
@@ -488,7 +503,7 @@ class Scope {
* @function Scope#isArgumentsMaterialized
* @returns {boolean} arguemnts materialized
*/
isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this
return true;
}
@@ -497,7 +512,7 @@ class Scope {
* @function Scope#isThisMaterialized
* @returns {boolean} this materialized
*/
isThisMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
isThisMaterialized() { // eslint-disable-line class-methods-use-this
return true;
}
@@ -514,9 +529,6 @@ class Scope {
}
}
/**
* Global scope.
*/
class GlobalScope extends Scope {
constructor(scopeManager, block) {
super(scopeManager, "global", null, block, false);
@@ -578,18 +590,12 @@ class GlobalScope extends Scope {
}
}
/**
* Module scope.
*/
class ModuleScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "module", upperScope, block, false);
}
}
/**
* Function expression name scope.
*/
class FunctionExpressionNameScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "function-expression-name", upperScope, block, false);
@@ -606,18 +612,12 @@ class FunctionExpressionNameScope extends Scope {
}
}
/**
* Catch scope.
*/
class CatchScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "catch", upperScope, block, false);
}
}
/**
* With statement scope.
*/
class WithScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "with", upperScope, block, false);
@@ -640,27 +640,18 @@ class WithScope extends Scope {
}
}
/**
* Block scope.
*/
class BlockScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "block", upperScope, block, false);
}
}
/**
* Switch scope.
*/
class SwitchScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "switch", upperScope, block, false);
}
}
/**
* Function scope.
*/
class FunctionScope extends Scope {
constructor(scopeManager, upperScope, block, isMethodDefinition) {
super(scopeManager, "function", upperScope, block, isMethodDefinition);
@@ -738,36 +729,24 @@ class FunctionScope extends Scope {
}
}
/**
* Scope of for, for-in, and for-of statements.
*/
class ForScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "for", upperScope, block, false);
}
}
/**
* Class scope.
*/
class ClassScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "class", upperScope, block, false);
}
}
/**
* Class field initializer scope.
*/
class ClassFieldInitializerScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "class-field-initializer", upperScope, block, true);
}
}
/**
* Class static block scope.
*/
class ClassStaticBlockScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "class-static-block", upperScope, block, true);
+1 -1
View File
@@ -1,3 +1,3 @@
const version = "8.4.0";
const version = "7.2.2";
export default version;