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:
1 parent
20129a1ac7
commit
ac4f232e5e
787 files changed
+82341
-121690
No files matched your search
+64
-87
@@ -23,7 +23,7 @@ const astUtils = require("./utils/ast-utils");
|
||||
* @returns {boolean} `true` if the array `arrA` is a subset of the array `arrB`.
|
||||
*/
|
||||
function isSubsetByComparator(comparator, arrA, arrB) {
|
||||
return arrA.every(a => arrB.some(b => comparator(a, b)));
|
||||
return arrA.every(a => arrB.some(b => comparator(a, b)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,13 +33,10 @@ function isSubsetByComparator(comparator, arrA, arrB) {
|
||||
* @returns {ASTNode[]} Array of conditions that makes the node when joined by the operator.
|
||||
*/
|
||||
function splitByLogicalOperator(operator, node) {
|
||||
if (node.type === "LogicalExpression" && node.operator === operator) {
|
||||
return [
|
||||
...splitByLogicalOperator(operator, node.left),
|
||||
...splitByLogicalOperator(operator, node.right),
|
||||
];
|
||||
}
|
||||
return [node];
|
||||
if (node.type === "LogicalExpression" && node.operator === operator) {
|
||||
return [...splitByLogicalOperator(operator, node.left), ...splitByLogicalOperator(operator, node.right)];
|
||||
}
|
||||
return [node];
|
||||
}
|
||||
|
||||
const splitByOr = splitByLogicalOperator.bind(null, "||");
|
||||
@@ -49,97 +46,77 @@ const splitByAnd = splitByLogicalOperator.bind(null, "&&");
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description: "Disallow duplicate conditions in if-else-if chains",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-dupe-else-if",
|
||||
},
|
||||
docs: {
|
||||
description: "Disallow duplicate conditions in if-else-if chains",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-dupe-else-if"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected:
|
||||
"This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain.",
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
unexpected: "This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
|
||||
* represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
|
||||
* @param {ASTNode} a First node.
|
||||
* @param {ASTNode} b Second node.
|
||||
* @returns {boolean} `true` if the nodes are considered to be equal.
|
||||
*/
|
||||
function equal(a, b) {
|
||||
if (a.type !== b.type) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
|
||||
* represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
|
||||
* @param {ASTNode} a First node.
|
||||
* @param {ASTNode} b Second node.
|
||||
* @returns {boolean} `true` if the nodes are considered to be equal.
|
||||
*/
|
||||
function equal(a, b) {
|
||||
if (a.type !== b.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
a.type === "LogicalExpression" &&
|
||||
(a.operator === "||" || a.operator === "&&") &&
|
||||
a.operator === b.operator
|
||||
) {
|
||||
return (
|
||||
(equal(a.left, b.left) && equal(a.right, b.right)) ||
|
||||
(equal(a.left, b.right) && equal(a.right, b.left))
|
||||
);
|
||||
}
|
||||
if (
|
||||
a.type === "LogicalExpression" &&
|
||||
(a.operator === "||" || a.operator === "&&") &&
|
||||
a.operator === b.operator
|
||||
) {
|
||||
return equal(a.left, b.left) && equal(a.right, b.right) ||
|
||||
equal(a.left, b.right) && equal(a.right, b.left);
|
||||
}
|
||||
|
||||
return astUtils.equalTokens(a, b, sourceCode);
|
||||
}
|
||||
return astUtils.equalTokens(a, b, sourceCode);
|
||||
}
|
||||
|
||||
const isSubset = isSubsetByComparator.bind(null, equal);
|
||||
const isSubset = isSubsetByComparator.bind(null, equal);
|
||||
|
||||
return {
|
||||
IfStatement(node) {
|
||||
const test = node.test,
|
||||
conditionsToCheck =
|
||||
test.type === "LogicalExpression" &&
|
||||
test.operator === "&&"
|
||||
? [test, ...splitByAnd(test)]
|
||||
: [test];
|
||||
let current = node,
|
||||
listToCheck = conditionsToCheck.map(c =>
|
||||
splitByOr(c).map(splitByAnd),
|
||||
);
|
||||
return {
|
||||
IfStatement(node) {
|
||||
const test = node.test,
|
||||
conditionsToCheck = test.type === "LogicalExpression" && test.operator === "&&"
|
||||
? [test, ...splitByAnd(test)]
|
||||
: [test];
|
||||
let current = node,
|
||||
listToCheck = conditionsToCheck.map(c => splitByOr(c).map(splitByAnd));
|
||||
|
||||
while (
|
||||
current.parent &&
|
||||
current.parent.type === "IfStatement" &&
|
||||
current.parent.alternate === current
|
||||
) {
|
||||
current = current.parent;
|
||||
while (current.parent && current.parent.type === "IfStatement" && current.parent.alternate === current) {
|
||||
current = current.parent;
|
||||
|
||||
const currentOrOperands = splitByOr(current.test).map(
|
||||
splitByAnd,
|
||||
);
|
||||
const currentOrOperands = splitByOr(current.test).map(splitByAnd);
|
||||
|
||||
listToCheck = listToCheck.map(orOperands =>
|
||||
orOperands.filter(
|
||||
orOperand =>
|
||||
!currentOrOperands.some(currentOrOperand =>
|
||||
isSubset(currentOrOperand, orOperand),
|
||||
),
|
||||
),
|
||||
);
|
||||
listToCheck = listToCheck.map(orOperands => orOperands.filter(
|
||||
orOperand => !currentOrOperands.some(currentOrOperand => isSubset(currentOrOperand, orOperand))
|
||||
));
|
||||
|
||||
if (
|
||||
listToCheck.some(orOperands => orOperands.length === 0)
|
||||
) {
|
||||
context.report({ node: test, messageId: "unexpected" });
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
if (listToCheck.some(orOperands => orOperands.length === 0)) {
|
||||
context.report({ node: test, messageId: "unexpected" });
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user