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 committed 2025-11-18 10:23:55 -03:00
1 parent 20129a1ac7
commit ac4f232e5e
787 files changed
+82341 -121690

No files matched your search

+95 -157
View File
@@ -10,186 +10,124 @@
//------------------------------------------------------------------------------
const {
getVariableByName,
isClosingParenToken,
isOpeningParenToken,
isStartOfExpressionStatement,
needsPrecedingSemicolon,
getVariableByName,
isClosingParenToken,
isOpeningParenToken,
isStartOfExpressionStatement,
needsPrecedingSemicolon
} = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
dialects: ["javascript", "typescript"],
language: "javascript",
type: "suggestion",
meta: {
type: "suggestion",
docs: {
description: "Disallow `Array` constructors",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-array-constructor",
},
docs: {
description: "Disallow `Array` constructors",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-array-constructor"
},
fixable: "code",
hasSuggestions: true,
hasSuggestions: true,
schema: [],
schema: [],
messages: {
preferLiteral: "The array literal notation [] is preferable.",
useLiteral: "Replace with an array literal.",
useLiteralAfterSemicolon: "Replace with an array literal, add preceding semicolon."
}
},
messages: {
preferLiteral: "The array literal notation [] is preferable.",
useLiteral: "Replace with an array literal.",
useLiteralAfterSemicolon:
"Replace with an array literal, add preceding semicolon.",
},
},
create(context) {
create(context) {
const sourceCode = context.sourceCode;
const sourceCode = context.sourceCode;
/**
* Checks if there are comments in Array constructor expressions.
* @param {ASTNode} node A CallExpression or NewExpression node.
* @returns {boolean} True if there are comments, false otherwise.
*/
function hasCommentsInArrayConstructor(node) {
const firstToken = sourceCode.getFirstToken(node);
const lastToken = sourceCode.getLastToken(node);
/**
* Gets the text between the calling parentheses of a CallExpression or NewExpression.
* @param {ASTNode} node A CallExpression or NewExpression node.
* @returns {string} The text between the calling parentheses, or an empty string if there are none.
*/
function getArgumentsText(node) {
const lastToken = sourceCode.getLastToken(node);
let lastRelevantToken = sourceCode.getLastToken(node.callee);
if (!isClosingParenToken(lastToken)) {
return "";
}
while (
lastRelevantToken !== lastToken &&
!isOpeningParenToken(lastRelevantToken)
) {
lastRelevantToken = sourceCode.getTokenAfter(lastRelevantToken);
}
let firstToken = node.callee;
return sourceCode.commentsExistBetween(
firstToken,
lastRelevantToken,
);
}
do {
firstToken = sourceCode.getTokenAfter(firstToken);
if (!firstToken || firstToken === lastToken) {
return "";
}
} while (!isOpeningParenToken(firstToken));
/**
* Gets the text between the calling parentheses of a CallExpression or NewExpression.
* @param {ASTNode} node A CallExpression or NewExpression node.
* @returns {string} The text between the calling parentheses, or an empty string if there are none.
*/
function getArgumentsText(node) {
const lastToken = sourceCode.getLastToken(node);
return sourceCode.text.slice(firstToken.range[1], lastToken.range[0]);
}
if (!isClosingParenToken(lastToken)) {
return "";
}
/**
* Disallow construction of dense arrays using the Array constructor
* @param {ASTNode} node node to evaluate
* @returns {void}
* @private
*/
function check(node) {
if (
node.callee.type !== "Identifier" ||
node.callee.name !== "Array" ||
node.arguments.length === 1 &&
node.arguments[0].type !== "SpreadElement") {
return;
}
let firstToken = node.callee;
const variable = getVariableByName(sourceCode.getScope(node), "Array");
do {
firstToken = sourceCode.getTokenAfter(firstToken);
if (!firstToken || firstToken === lastToken) {
return "";
}
} while (!isOpeningParenToken(firstToken));
/*
* Check if `Array` is a predefined global variable: predefined globals have no declarations,
* meaning that the `identifiers` list of the variable object is empty.
*/
if (variable && variable.identifiers.length === 0) {
const argsText = getArgumentsText(node);
let fixText;
let messageId;
return sourceCode.text.slice(
firstToken.range[1],
lastToken.range[0],
);
}
/*
* Check if the suggested change should include a preceding semicolon or not.
* Due to JavaScript's ASI rules, a missing semicolon may be inserted automatically
* before an expression like `Array()` or `new Array()`, but not when the expression
* is changed into an array literal like `[]`.
*/
if (isStartOfExpressionStatement(node) && needsPrecedingSemicolon(sourceCode, node)) {
fixText = `;[${argsText}]`;
messageId = "useLiteralAfterSemicolon";
} else {
fixText = `[${argsText}]`;
messageId = "useLiteral";
}
/**
* Disallow construction of dense arrays using the Array constructor
* @param {ASTNode} node node to evaluate
* @returns {void}
* @private
*/
function check(node) {
if (
node.callee.type !== "Identifier" ||
node.callee.name !== "Array" ||
node.typeArguments ||
(node.arguments.length === 1 &&
node.arguments[0].type !== "SpreadElement")
) {
return;
}
context.report({
node,
messageId: "preferLiteral",
suggest: [
{
messageId,
fix: fixer => fixer.replaceText(node, fixText)
}
]
});
}
}
const variable = getVariableByName(
sourceCode.getScope(node),
"Array",
);
return {
CallExpression: check,
NewExpression: check
};
/*
* Check if `Array` is a predefined global variable: predefined globals have no declarations,
* meaning that the `identifiers` list of the variable object is empty.
*/
if (variable && variable.identifiers.length === 0) {
const argsText = getArgumentsText(node);
let fixText;
let messageId;
const nonSpreadCount = node.arguments.reduce(
(count, arg) =>
arg.type !== "SpreadElement" ? count + 1 : count,
0,
);
const shouldSuggest =
node.optional ||
(node.arguments.length > 0 && nonSpreadCount < 2) ||
hasCommentsInArrayConstructor(node);
/*
* Check if the suggested change should include a preceding semicolon or not.
* Due to JavaScript's ASI rules, a missing semicolon may be inserted automatically
* before an expression like `Array()` or `new Array()`, but not when the expression
* is changed into an array literal like `[]`.
*/
if (
isStartOfExpressionStatement(node) &&
needsPrecedingSemicolon(sourceCode, node)
) {
fixText = `;[${argsText}]`;
messageId = "useLiteralAfterSemicolon";
} else {
fixText = `[${argsText}]`;
messageId = "useLiteral";
}
context.report({
node,
messageId: "preferLiteral",
fix(fixer) {
if (shouldSuggest) {
return null;
}
return fixer.replaceText(node, fixText);
},
suggest: [
{
messageId,
fix(fixer) {
if (shouldSuggest) {
return fixer.replaceText(node, fixText);
}
return null;
},
},
],
});
}
}
return {
CallExpression: check,
NewExpression: check,
};
},
}
};