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
+115 -179
View File
@@ -22,13 +22,14 @@ const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
* @returns {boolean} True if any segment is reachable; false otherwise.
*/
function isAnySegmentReachable(segments) {
for (const segment of segments) {
if (segment.reachable) {
return true;
}
}
return false;
for (const segment of segments) {
if (segment.reachable) {
return true;
}
}
return false;
}
/**
@@ -38,10 +39,7 @@ function isAnySegmentReachable(segments) {
* @returns {boolean} `true` if the comment string is truly a fallthrough comment.
*/
function isFallThroughComment(comment, fallthroughCommentPattern) {
return (
fallthroughCommentPattern.test(comment) &&
!directivesPattern.test(comment.trim())
);
return fallthroughCommentPattern.test(comment) && !directivesPattern.test(comment.trim());
}
/**
@@ -50,48 +48,23 @@ function isFallThroughComment(comment, fallthroughCommentPattern) {
* @param {ASTNode} subsequentCase The case after caseWhichFallsThrough.
* @param {RuleContext} context A rule context which stores comments.
* @param {RegExp} fallthroughCommentPattern A pattern to match comment to.
* @returns {null | object} the comment if the case has a valid fallthrough comment, otherwise null
* @returns {boolean} `true` if the case has a valid fallthrough comment.
*/
function getFallthroughComment(
caseWhichFallsThrough,
subsequentCase,
context,
fallthroughCommentPattern,
) {
const sourceCode = context.sourceCode;
function hasFallthroughComment(caseWhichFallsThrough, subsequentCase, context, fallthroughCommentPattern) {
const sourceCode = context.sourceCode;
if (
caseWhichFallsThrough.consequent.length === 1 &&
caseWhichFallsThrough.consequent[0].type === "BlockStatement"
) {
const trailingCloseBrace = sourceCode.getLastToken(
caseWhichFallsThrough.consequent[0],
);
const commentInBlock = sourceCode
.getCommentsBefore(trailingCloseBrace)
.pop();
if (caseWhichFallsThrough.consequent.length === 1 && caseWhichFallsThrough.consequent[0].type === "BlockStatement") {
const trailingCloseBrace = sourceCode.getLastToken(caseWhichFallsThrough.consequent[0]);
const commentInBlock = sourceCode.getCommentsBefore(trailingCloseBrace).pop();
if (
commentInBlock &&
isFallThroughComment(
commentInBlock.value,
fallthroughCommentPattern,
)
) {
return commentInBlock;
}
}
if (commentInBlock && isFallThroughComment(commentInBlock.value, fallthroughCommentPattern)) {
return true;
}
}
const comment = sourceCode.getCommentsBefore(subsequentCase).pop();
const comment = sourceCode.getCommentsBefore(subsequentCase).pop();
if (
comment &&
isFallThroughComment(comment.value, fallthroughCommentPattern)
) {
return comment;
}
return null;
return Boolean(comment && isFallThroughComment(comment.value, fallthroughCommentPattern));
}
/**
@@ -101,160 +74,123 @@ function getFallthroughComment(
* @returns {boolean} `true` if there are blank lines between node and token
*/
function hasBlankLinesBetween(node, token) {
return token.loc.start.line > node.loc.end.line + 1;
return token.loc.start.line > node.loc.end.line + 1;
}
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "problem",
meta: {
type: "problem",
defaultOptions: [
{
allowEmptyCase: false,
reportUnusedFallthroughComment: false,
},
],
docs: {
description: "Disallow fallthrough of `case` statements",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-fallthrough"
},
docs: {
description: "Disallow fallthrough of `case` statements",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-fallthrough",
},
schema: [
{
type: "object",
properties: {
commentPattern: {
type: "string",
default: ""
},
allowEmptyCase: {
type: "boolean",
default: false
}
},
additionalProperties: false
}
],
messages: {
case: "Expected a 'break' statement before 'case'.",
default: "Expected a 'break' statement before 'default'."
}
},
schema: [
{
type: "object",
properties: {
commentPattern: {
type: "string",
},
allowEmptyCase: {
type: "boolean",
},
reportUnusedFallthroughComment: {
type: "boolean",
},
},
additionalProperties: false,
},
],
messages: {
unusedFallthroughComment:
"Found a comment that would permit fallthrough, but case cannot fall through.",
case: "Expected a 'break' statement before 'case'.",
default: "Expected a 'break' statement before 'default'.",
},
},
create(context) {
const options = context.options[0] || {};
const codePathSegments = [];
let currentCodePathSegments = new Set();
const sourceCode = context.sourceCode;
const allowEmptyCase = options.allowEmptyCase || false;
create(context) {
const codePathSegments = [];
let currentCodePathSegments = new Set();
const sourceCode = context.sourceCode;
const [
{ allowEmptyCase, commentPattern, reportUnusedFallthroughComment },
] = context.options;
const fallthroughCommentPattern = commentPattern
? new RegExp(commentPattern, "u")
: DEFAULT_FALLTHROUGH_COMMENT;
/*
* We need to use leading comments of the next SwitchCase node because
* trailing comments is wrong if semicolons are omitted.
*/
let fallthroughCase = null;
let fallthroughCommentPattern = null;
/*
* We need to use leading comments of the next SwitchCase node because
* trailing comments is wrong if semicolons are omitted.
*/
let previousCase = null;
if (options.commentPattern) {
fallthroughCommentPattern = new RegExp(options.commentPattern, "u");
} else {
fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT;
}
return {
return {
onCodePathStart() {
codePathSegments.push(currentCodePathSegments);
currentCodePathSegments = new Set();
},
onCodePathStart() {
codePathSegments.push(currentCodePathSegments);
currentCodePathSegments = new Set();
},
onCodePathEnd() {
currentCodePathSegments = codePathSegments.pop();
},
onCodePathEnd() {
currentCodePathSegments = codePathSegments.pop();
},
onUnreachableCodePathSegmentStart(segment) {
currentCodePathSegments.add(segment);
},
onUnreachableCodePathSegmentStart(segment) {
currentCodePathSegments.add(segment);
},
onUnreachableCodePathSegmentEnd(segment) {
currentCodePathSegments.delete(segment);
},
onUnreachableCodePathSegmentEnd(segment) {
currentCodePathSegments.delete(segment);
},
onCodePathSegmentStart(segment) {
currentCodePathSegments.add(segment);
},
onCodePathSegmentStart(segment) {
currentCodePathSegments.add(segment);
},
onCodePathSegmentEnd(segment) {
currentCodePathSegments.delete(segment);
},
onCodePathSegmentEnd(segment) {
currentCodePathSegments.delete(segment);
},
SwitchCase(node) {
/*
* Checks whether or not there is a fallthrough comment.
* And reports the previous fallthrough node if that does not exist.
*/
if (previousCase && previousCase.node.parent === node.parent) {
const previousCaseFallthroughComment =
getFallthroughComment(
previousCase.node,
node,
context,
fallthroughCommentPattern,
);
SwitchCase(node) {
if (
previousCase.isFallthrough &&
!previousCaseFallthroughComment
) {
context.report({
messageId: node.test ? "case" : "default",
node,
});
} else if (
reportUnusedFallthroughComment &&
!previousCase.isSwitchExitReachable &&
previousCaseFallthroughComment
) {
context.report({
messageId: "unusedFallthroughComment",
node: previousCaseFallthroughComment,
});
}
}
previousCase = null;
},
/*
* Checks whether or not there is a fallthrough comment.
* And reports the previous fallthrough node if that does not exist.
*/
"SwitchCase:exit"(node) {
const nextToken = sourceCode.getTokenAfter(node);
if (fallthroughCase && (!hasFallthroughComment(fallthroughCase, node, context, fallthroughCommentPattern))) {
context.report({
messageId: node.test ? "case" : "default",
node
});
}
fallthroughCase = null;
},
/*
* `reachable` meant fall through because statements preceded by
* `break`, `return`, or `throw` are unreachable.
* And allows empty cases and the last case.
*/
const isSwitchExitReachable = isAnySegmentReachable(
currentCodePathSegments,
);
const isFallthrough =
isSwitchExitReachable &&
(node.consequent.length > 0 ||
(!allowEmptyCase &&
hasBlankLinesBetween(node, nextToken))) &&
node.parent.cases.at(-1) !== node;
"SwitchCase:exit"(node) {
const nextToken = sourceCode.getTokenAfter(node);
previousCase = {
node,
isSwitchExitReachable,
isFallthrough,
};
},
};
},
/*
* `reachable` meant fall through because statements preceded by
* `break`, `return`, or `throw` are unreachable.
* And allows empty cases and the last case.
*/
if (isAnySegmentReachable(currentCodePathSegments) &&
(node.consequent.length > 0 || (!allowEmptyCase && hasBlankLinesBetween(node, nextToken))) &&
node.parent.cases[node.parent.cases.length - 1] !== node) {
fallthroughCase = node;
}
}
};
}
};