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
+119 -137
View File
@@ -16,11 +16,9 @@ const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
const MODE_ALWAYS = "always",
MODE_AS_NEEDED = "as-needed";
MODE_AS_NEEDED = "as-needed";
const validRadixValues = new Set(
Array.from({ length: 37 - 2 }, (_, index) => index + 2),
);
const validRadixValues = new Set(Array.from({ length: 37 - 2 }, (_, index) => index + 2));
/**
* Checks whether a given variable is shadowed or not.
@@ -28,7 +26,7 @@ const validRadixValues = new Set(
* @returns {boolean} `true` if the variable is shadowed.
*/
function isShadowed(variable) {
return variable.defs.length >= 1;
return variable.defs.length >= 1;
}
/**
@@ -38,12 +36,12 @@ function isShadowed(variable) {
* method.
*/
function isParseIntMethod(node) {
return (
node.type === "MemberExpression" &&
!node.computed &&
node.property.type === "Identifier" &&
node.property.name === "parseInt"
);
return (
node.type === "MemberExpression" &&
!node.computed &&
node.property.type === "Identifier" &&
node.property.name === "parseInt"
);
}
/**
@@ -57,10 +55,10 @@ function isParseIntMethod(node) {
* @returns {boolean} `true` if the node is valid.
*/
function isValidRadix(radix) {
return !(
(radix.type === "Literal" && !validRadixValues.has(radix.value)) ||
(radix.type === "Identifier" && radix.name === "undefined")
);
return !(
(radix.type === "Literal" && !validRadixValues.has(radix.value)) ||
(radix.type === "Identifier" && radix.name === "undefined")
);
}
/**
@@ -69,148 +67,132 @@ function isValidRadix(radix) {
* @returns {boolean} `true` if the node is the literal node of `10`.
*/
function isDefaultRadix(radix) {
return radix.type === "Literal" && radix.value === 10;
return radix.type === "Literal" && radix.value === 10;
}
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
meta: {
type: "suggestion",
defaultOptions: [MODE_ALWAYS],
docs: {
description: "Enforce the consistent use of the radix argument when using `parseInt()`",
recommended: false,
url: "https://eslint.org/docs/latest/rules/radix"
},
docs: {
description:
"Enforce the consistent use of the radix argument when using `parseInt()`",
recommended: false,
url: "https://eslint.org/docs/latest/rules/radix",
},
hasSuggestions: true,
hasSuggestions: true,
schema: [
{
enum: ["always", "as-needed"]
}
],
schema: [
{
enum: ["always", "as-needed"],
},
],
messages: {
missingParameters: "Missing parameters.",
redundantRadix: "Redundant radix parameter.",
missingRadix: "Missing radix parameter.",
invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36.",
addRadixParameter10: "Add radix parameter `10` for parsing decimal numbers."
}
},
messages: {
missingParameters: "Missing parameters.",
redundantRadix: "Redundant radix parameter.",
missingRadix: "Missing radix parameter.",
invalidRadix:
"Invalid radix parameter, must be an integer between 2 and 36.",
addRadixParameter10:
"Add radix parameter `10` for parsing decimal numbers.",
},
},
create(context) {
const mode = context.options[0] || MODE_ALWAYS;
const sourceCode = context.sourceCode;
create(context) {
const [mode] = context.options;
const sourceCode = context.sourceCode;
/**
* Checks the arguments of a given CallExpression node and reports it if it
* offends this rule.
* @param {ASTNode} node A CallExpression node to check.
* @returns {void}
*/
function checkArguments(node) {
const args = node.arguments;
/**
* Checks the arguments of a given CallExpression node and reports it if it
* offends this rule.
* @param {ASTNode} node A CallExpression node to check.
* @returns {void}
*/
function checkArguments(node) {
const args = node.arguments;
switch (args.length) {
case 0:
context.report({
node,
messageId: "missingParameters"
});
break;
switch (args.length) {
case 0:
context.report({
node,
messageId: "missingParameters",
});
break;
case 1:
if (mode === MODE_ALWAYS) {
context.report({
node,
messageId: "missingRadix",
suggest: [
{
messageId: "addRadixParameter10",
fix(fixer) {
const tokens = sourceCode.getTokens(node);
const lastToken = tokens[tokens.length - 1]; // Parenthesis.
const secondToLastToken = tokens[tokens.length - 2]; // May or may not be a comma.
const hasTrailingComma = secondToLastToken.type === "Punctuator" && secondToLastToken.value === ",";
case 1:
if (mode === MODE_ALWAYS) {
context.report({
node,
messageId: "missingRadix",
suggest: [
{
messageId: "addRadixParameter10",
fix(fixer) {
const tokens =
sourceCode.getTokens(node);
const lastToken = tokens.at(-1); // Parenthesis.
const secondToLastToken = tokens.at(-2); // May or may not be a comma.
const hasTrailingComma =
secondToLastToken.type ===
"Punctuator" &&
secondToLastToken.value === ",";
return fixer.insertTextBefore(lastToken, hasTrailingComma ? " 10," : ", 10");
}
}
]
});
}
break;
return fixer.insertTextBefore(
lastToken,
hasTrailingComma ? " 10," : ", 10",
);
},
},
],
});
}
break;
default:
if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) {
context.report({
node,
messageId: "redundantRadix"
});
} else if (!isValidRadix(args[1])) {
context.report({
node,
messageId: "invalidRadix"
});
}
break;
}
}
default:
if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) {
context.report({
node,
messageId: "redundantRadix",
});
} else if (!isValidRadix(args[1])) {
context.report({
node,
messageId: "invalidRadix",
});
}
break;
}
}
return {
"Program:exit"(node) {
const scope = sourceCode.getScope(node);
let variable;
return {
"Program:exit"(node) {
const scope = sourceCode.getScope(node);
let variable;
// Check `parseInt()`
variable = astUtils.getVariableByName(scope, "parseInt");
if (variable && !isShadowed(variable)) {
variable.references.forEach(reference => {
const idNode = reference.identifier;
// Check `parseInt()`
variable = astUtils.getVariableByName(scope, "parseInt");
if (variable && !isShadowed(variable)) {
variable.references.forEach(reference => {
const idNode = reference.identifier;
if (astUtils.isCallee(idNode)) {
checkArguments(idNode.parent);
}
});
}
if (astUtils.isCallee(idNode)) {
checkArguments(idNode.parent);
}
});
}
// Check `Number.parseInt()`
variable = astUtils.getVariableByName(scope, "Number");
if (variable && !isShadowed(variable)) {
variable.references.forEach(reference => {
const parentNode = reference.identifier.parent;
const maybeCallee = parentNode.parent.type === "ChainExpression"
? parentNode.parent
: parentNode;
// Check `Number.parseInt()`
variable = astUtils.getVariableByName(scope, "Number");
if (variable && !isShadowed(variable)) {
variable.references.forEach(reference => {
const parentNode = reference.identifier.parent;
const maybeCallee =
parentNode.parent.type === "ChainExpression"
? parentNode.parent
: parentNode;
if (
isParseIntMethod(parentNode) &&
astUtils.isCallee(maybeCallee)
) {
checkArguments(maybeCallee.parent);
}
});
}
},
};
},
if (isParseIntMethod(parentNode) && astUtils.isCallee(maybeCallee)) {
checkArguments(maybeCallee.parent);
}
});
}
}
};
}
};