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

+175 -253
View File
@@ -10,8 +10,8 @@
const NAMED_TYPES = ["ImportSpecifier", "ExportSpecifier"];
const NAMESPACE_TYPES = [
"ImportNamespaceSpecifier",
"ExportNamespaceSpecifier",
"ImportNamespaceSpecifier",
"ExportNamespaceSpecifier"
];
//------------------------------------------------------------------------------
@@ -25,9 +25,9 @@ const NAMESPACE_TYPES = [
* @returns {boolean} True if import/export type belongs to (ImportSpecifier|ExportSpecifier) or (ImportNamespaceSpecifier|ExportNamespaceSpecifier) and false if it doesn't.
*/
function isImportExportSpecifier(importExportType, type) {
const arrayToCheck = type === "named" ? NAMED_TYPES : NAMESPACE_TYPES;
const arrayToCheck = type === "named" ? NAMED_TYPES : NAMESPACE_TYPES;
return arrayToCheck.includes(importExportType);
return arrayToCheck.includes(importExportType);
}
/**
@@ -36,24 +36,24 @@ function isImportExportSpecifier(importExportType, type) {
* @returns {string} The type of the (import|export).
*/
function getImportExportType(node) {
if (node.specifiers && node.specifiers.length > 0) {
const nodeSpecifiers = node.specifiers;
const index = nodeSpecifiers.findIndex(
({ type }) =>
isImportExportSpecifier(type, "named") ||
isImportExportSpecifier(type, "namespace"),
);
const i = index > -1 ? index : 0;
if (node.specifiers && node.specifiers.length > 0) {
const nodeSpecifiers = node.specifiers;
const index = nodeSpecifiers.findIndex(
({ type }) =>
isImportExportSpecifier(type, "named") ||
isImportExportSpecifier(type, "namespace")
);
const i = index > -1 ? index : 0;
return nodeSpecifiers[i].type;
}
if (node.type === "ExportAllDeclaration") {
if (node.exported) {
return "ExportNamespaceSpecifier";
}
return "ExportAll";
}
return "SideEffectImport";
return nodeSpecifiers[i].type;
}
if (node.type === "ExportAllDeclaration") {
if (node.exported) {
return "ExportNamespaceSpecifier";
}
return "ExportAll";
}
return "SideEffectImport";
}
/**
@@ -63,80 +63,46 @@ function getImportExportType(node) {
* @returns {boolean} True if two (import|export) can be merged, false if they can't.
*/
function isImportExportCanBeMerged(node1, node2) {
const importExportType1 = getImportExportType(node1);
const importExportType2 = getImportExportType(node2);
const importExportType1 = getImportExportType(node1);
const importExportType2 = getImportExportType(node2);
if (
(node1.importKind === "type" || node1.exportKind === "type") &&
(node2.importKind === "type" || node2.exportKind === "type")
) {
const isDefault1 = importExportType1 === "ImportDefaultSpecifier";
const isDefault2 = importExportType2 === "ImportDefaultSpecifier";
const isNamed1 = isImportExportSpecifier(importExportType1, "named");
const isNamed2 = isImportExportSpecifier(importExportType2, "named");
if ((isDefault1 && isNamed2) || (isDefault2 && isNamed1)) {
return false;
}
}
if (
(importExportType1 === "ExportAll" &&
importExportType2 !== "ExportAll" &&
importExportType2 !== "SideEffectImport") ||
(importExportType1 !== "ExportAll" &&
importExportType1 !== "SideEffectImport" &&
importExportType2 === "ExportAll")
) {
return false;
}
if (
(isImportExportSpecifier(importExportType1, "namespace") &&
isImportExportSpecifier(importExportType2, "named")) ||
(isImportExportSpecifier(importExportType2, "namespace") &&
isImportExportSpecifier(importExportType1, "named"))
) {
return false;
}
return true;
if (
(importExportType1 === "ExportAll" &&
importExportType2 !== "ExportAll" &&
importExportType2 !== "SideEffectImport") ||
(importExportType1 !== "ExportAll" &&
importExportType1 !== "SideEffectImport" &&
importExportType2 === "ExportAll")
) {
return false;
}
if (
(isImportExportSpecifier(importExportType1, "namespace") &&
isImportExportSpecifier(importExportType2, "named")) ||
(isImportExportSpecifier(importExportType2, "namespace") &&
isImportExportSpecifier(importExportType1, "named"))
) {
return false;
}
return true;
}
/**
* Returns a boolean if we should report (import|export).
* @param {ASTNode} node A node to be reported or not.
* @param {[ASTNode]} previousNodes An array contains previous nodes of the module imported or exported.
* @param {boolean} allowSeparateTypeImports Whether to allow separate type and value imports.
* @returns {boolean} True if the (import|export) should be reported.
*/
function shouldReportImportExport(
node,
previousNodes,
allowSeparateTypeImports,
) {
let i = 0;
function shouldReportImportExport(node, previousNodes) {
let i = 0;
while (i < previousNodes.length) {
const previousNode = previousNodes[i];
if (allowSeparateTypeImports) {
const isTypeNode =
node.importKind === "type" || node.exportKind === "type";
const isTypePrevious =
previousNode.importKind === "type" ||
previousNode.exportKind === "type";
if (isTypeNode !== isTypePrevious) {
i++;
continue;
}
}
if (isImportExportCanBeMerged(node, previousNode)) {
return true;
}
i++;
}
return false;
while (i < previousNodes.length) {
if (isImportExportCanBeMerged(node, previousNodes[i])) {
return true;
}
i++;
}
return false;
}
/**
@@ -146,9 +112,9 @@ function shouldReportImportExport(
* @returns {[ASTNode]} An array contains only nodes with declarations types equal to type.
*/
function getNodesByDeclarationType(nodes, type) {
return nodes
.filter(({ declarationType }) => declarationType === type)
.map(({ node }) => node);
return nodes
.filter(({ declarationType }) => declarationType === type)
.map(({ node }) => node);
}
/**
@@ -157,10 +123,10 @@ function getNodesByDeclarationType(nodes, type) {
* @returns {string} The name of the module, or empty string if no name.
*/
function getModule(node) {
if (node && node.source && node.source.value) {
return node.source.value.trim();
}
return "";
if (node && node.source && node.source.value) {
return node.source.value.trim();
}
return "";
}
/**
@@ -170,79 +136,52 @@ function getModule(node) {
* @param {Map} modules A Map object contains as a key a module name and as value an array contains objects, each object contains a node and a declaration type.
* @param {string} declarationType A declaration type can be an import or export.
* @param {boolean} includeExports Whether or not to check for exports in addition to imports.
* @param {boolean} allowSeparateTypeImports Whether to allow separate type and value imports.
* @returns {void} No return value.
*/
function checkAndReport(
context,
node,
modules,
declarationType,
includeExports,
allowSeparateTypeImports,
context,
node,
modules,
declarationType,
includeExports
) {
const module = getModule(node);
const module = getModule(node);
if (modules.has(module)) {
const previousNodes = modules.get(module);
const messagesIds = [];
const importNodes = getNodesByDeclarationType(previousNodes, "import");
let exportNodes;
if (modules.has(module)) {
const previousNodes = modules.get(module);
const messagesIds = [];
const importNodes = getNodesByDeclarationType(previousNodes, "import");
let exportNodes;
if (includeExports) {
exportNodes = getNodesByDeclarationType(previousNodes, "export");
}
if (declarationType === "import") {
if (
shouldReportImportExport(
node,
importNodes,
allowSeparateTypeImports,
)
) {
messagesIds.push("import");
}
if (includeExports) {
if (
shouldReportImportExport(
node,
exportNodes,
allowSeparateTypeImports,
)
) {
messagesIds.push("importAs");
}
}
} else if (declarationType === "export") {
if (
shouldReportImportExport(
node,
exportNodes,
allowSeparateTypeImports,
)
) {
messagesIds.push("export");
}
if (
shouldReportImportExport(
node,
importNodes,
allowSeparateTypeImports,
)
) {
messagesIds.push("exportAs");
}
}
messagesIds.forEach(messageId =>
context.report({
node,
messageId,
data: {
module,
},
}),
);
}
if (includeExports) {
exportNodes = getNodesByDeclarationType(previousNodes, "export");
}
if (declarationType === "import") {
if (shouldReportImportExport(node, importNodes)) {
messagesIds.push("import");
}
if (includeExports) {
if (shouldReportImportExport(node, exportNodes)) {
messagesIds.push("importAs");
}
}
} else if (declarationType === "export") {
if (shouldReportImportExport(node, exportNodes)) {
messagesIds.push("export");
}
if (shouldReportImportExport(node, importNodes)) {
messagesIds.push("exportAs");
}
}
messagesIds.forEach(messageId =>
context.report({
node,
messageId,
data: {
module
}
}));
}
}
/**
@@ -256,113 +195,96 @@ function checkAndReport(
* @param {Map} modules A Map object contains as a key a module name and as value an array contains objects, each object contains a node and a declaration type.
* @param {string} declarationType A declaration type can be an import or export.
* @param {boolean} includeExports Whether or not to check for exports in addition to imports.
* @param {boolean} allowSeparateTypeImports Whether to allow separate type and value imports.
* @returns {nodeCallback} A function passed to ESLint to handle the statement.
*/
function handleImportsExports(
context,
modules,
declarationType,
includeExports,
allowSeparateTypeImports,
context,
modules,
declarationType,
includeExports
) {
return function (node) {
const module = getModule(node);
return function(node) {
const module = getModule(node);
if (module) {
checkAndReport(
context,
node,
modules,
declarationType,
includeExports,
allowSeparateTypeImports,
);
const currentNode = { node, declarationType };
let nodes = [currentNode];
if (module) {
checkAndReport(
context,
node,
modules,
declarationType,
includeExports
);
const currentNode = { node, declarationType };
let nodes = [currentNode];
if (modules.has(module)) {
const previousNodes = modules.get(module);
if (modules.has(module)) {
const previousNodes = modules.get(module);
nodes = [...previousNodes, currentNode];
}
modules.set(module, nodes);
}
};
nodes = [...previousNodes, currentNode];
}
modules.set(module, nodes);
}
};
}
/** @type {import('../types').Rule.RuleModule} */
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
dialects: ["javascript", "typescript"],
language: "javascript",
type: "problem",
meta: {
type: "problem",
defaultOptions: [
{
includeExports: false,
allowSeparateTypeImports: false,
},
],
docs: {
description: "Disallow duplicate module imports",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-duplicate-imports"
},
docs: {
description: "Disallow duplicate module imports",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-duplicate-imports",
},
schema: [
{
type: "object",
properties: {
includeExports: {
type: "boolean",
default: false
}
},
additionalProperties: false
}
],
schema: [
{
type: "object",
properties: {
includeExports: {
type: "boolean",
},
allowSeparateTypeImports: {
type: "boolean",
},
},
additionalProperties: false,
},
],
messages: {
import: "'{{module}}' import is duplicated.",
importAs: "'{{module}}' import is duplicated as export.",
export: "'{{module}}' export is duplicated.",
exportAs: "'{{module}}' export is duplicated as import."
}
},
messages: {
import: "'{{module}}' import is duplicated.",
importAs: "'{{module}}' import is duplicated as export.",
export: "'{{module}}' export is duplicated.",
exportAs: "'{{module}}' export is duplicated as import.",
},
},
create(context) {
const includeExports = (context.options[0] || {}).includeExports,
modules = new Map();
const handlers = {
ImportDeclaration: handleImportsExports(
context,
modules,
"import",
includeExports
)
};
create(context) {
const [{ includeExports, allowSeparateTypeImports }] = context.options;
const modules = new Map();
const handlers = {
ImportDeclaration: handleImportsExports(
context,
modules,
"import",
includeExports,
allowSeparateTypeImports,
),
};
if (includeExports) {
handlers.ExportNamedDeclaration = handleImportsExports(
context,
modules,
"export",
includeExports,
allowSeparateTypeImports,
);
handlers.ExportAllDeclaration = handleImportsExports(
context,
modules,
"export",
includeExports,
allowSeparateTypeImports,
);
}
return handlers;
},
if (includeExports) {
handlers.ExportNamedDeclaration = handleImportsExports(
context,
modules,
"export",
includeExports
);
handlers.ExportAllDeclaration = handleImportsExports(
context,
modules,
"export",
includeExports
);
}
return handlers;
}
};