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
+150
-181
@@ -24,215 +24,184 @@ const eslintUtils = require("@eslint-community/eslint-utils");
|
||||
* @private
|
||||
*/
|
||||
function isCalleeOfNewExpression(node) {
|
||||
const maybeCallee =
|
||||
node.parent.type === "ChainExpression" ? node.parent : node;
|
||||
const maybeCallee = node.parent.type === "ChainExpression"
|
||||
? node.parent
|
||||
: node;
|
||||
|
||||
return (
|
||||
maybeCallee.parent.type === "NewExpression" &&
|
||||
maybeCallee.parent.callee === maybeCallee
|
||||
);
|
||||
return (
|
||||
maybeCallee.parent.type === "NewExpression" &&
|
||||
maybeCallee.parent.callee === maybeCallee
|
||||
);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Formatting rules are being moved out of ESLint core.",
|
||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
||||
deprecatedSince: "8.53.0",
|
||||
availableUntil: "11.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin",
|
||||
url: "https://eslint.style",
|
||||
},
|
||||
rule: {
|
||||
name: "wrap-iife",
|
||||
url: "https://eslint.style/rules/wrap-iife",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
meta: {
|
||||
deprecated: true,
|
||||
replacedBy: [],
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Require parentheses around immediate `function` invocations",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/wrap-iife",
|
||||
},
|
||||
docs: {
|
||||
description: "Require parentheses around immediate `function` invocations",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/wrap-iife"
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["outside", "inside", "any"],
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
functionPrototypeMethods: {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
schema: [
|
||||
{
|
||||
enum: ["outside", "inside", "any"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
functionPrototypeMethods: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
|
||||
fixable: "code",
|
||||
messages: {
|
||||
wrapInvocation:
|
||||
"Wrap an immediate function invocation in parentheses.",
|
||||
wrapExpression: "Wrap only the function expression in parens.",
|
||||
moveInvocation:
|
||||
"Move the invocation into the parens that contain the function.",
|
||||
},
|
||||
},
|
||||
fixable: "code",
|
||||
messages: {
|
||||
wrapInvocation: "Wrap an immediate function invocation in parentheses.",
|
||||
wrapExpression: "Wrap only the function expression in parens.",
|
||||
moveInvocation: "Move the invocation into the parens that contain the function."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const style = context.options[0] || "outside";
|
||||
const includeFunctionPrototypeMethods =
|
||||
context.options[1] && context.options[1].functionPrototypeMethods;
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
const style = context.options[0] || "outside";
|
||||
const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
|
||||
|
||||
/**
|
||||
* Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if()
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {boolean} True if it is wrapped in any parens
|
||||
* @private
|
||||
*/
|
||||
function isWrappedInAnyParens(node) {
|
||||
return astUtils.isParenthesised(sourceCode, node);
|
||||
}
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Check if the node is wrapped in grouping (). Parens for constructs such as if() don't count
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {boolean} True if it is wrapped in grouping parens
|
||||
* @private
|
||||
*/
|
||||
function isWrappedInGroupingParens(node) {
|
||||
return eslintUtils.isParenthesized(1, node, sourceCode);
|
||||
}
|
||||
/**
|
||||
* Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if()
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {boolean} True if it is wrapped in any parens
|
||||
* @private
|
||||
*/
|
||||
function isWrappedInAnyParens(node) {
|
||||
return astUtils.isParenthesised(sourceCode, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the function node from an IIFE
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {ASTNode} node that is the function expression of the given IIFE, or null if none exist
|
||||
*/
|
||||
function getFunctionNodeFromIIFE(node) {
|
||||
const callee = astUtils.skipChainExpression(node.callee);
|
||||
/**
|
||||
* Check if the node is wrapped in grouping (). Parens for constructs such as if() don't count
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {boolean} True if it is wrapped in grouping parens
|
||||
* @private
|
||||
*/
|
||||
function isWrappedInGroupingParens(node) {
|
||||
return eslintUtils.isParenthesized(1, node, sourceCode);
|
||||
}
|
||||
|
||||
if (callee.type === "FunctionExpression") {
|
||||
return callee;
|
||||
}
|
||||
/**
|
||||
* Get the function node from an IIFE
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {ASTNode} node that is the function expression of the given IIFE, or null if none exist
|
||||
*/
|
||||
function getFunctionNodeFromIIFE(node) {
|
||||
const callee = astUtils.skipChainExpression(node.callee);
|
||||
|
||||
if (
|
||||
includeFunctionPrototypeMethods &&
|
||||
callee.type === "MemberExpression" &&
|
||||
callee.object.type === "FunctionExpression" &&
|
||||
(astUtils.getStaticPropertyName(callee) === "call" ||
|
||||
astUtils.getStaticPropertyName(callee) === "apply")
|
||||
) {
|
||||
return callee.object;
|
||||
}
|
||||
if (callee.type === "FunctionExpression") {
|
||||
return callee;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
if (includeFunctionPrototypeMethods &&
|
||||
callee.type === "MemberExpression" &&
|
||||
callee.object.type === "FunctionExpression" &&
|
||||
(astUtils.getStaticPropertyName(callee) === "call" || astUtils.getStaticPropertyName(callee) === "apply")
|
||||
) {
|
||||
return callee.object;
|
||||
}
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
const innerNode = getFunctionNodeFromIIFE(node);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!innerNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isCallExpressionWrapped = isWrappedInAnyParens(node),
|
||||
isFunctionExpressionWrapped =
|
||||
isWrappedInAnyParens(innerNode);
|
||||
return {
|
||||
CallExpression(node) {
|
||||
const innerNode = getFunctionNodeFromIIFE(node);
|
||||
|
||||
if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrapInvocation",
|
||||
fix(fixer) {
|
||||
const nodeToSurround =
|
||||
style === "inside" ? innerNode : node;
|
||||
if (!innerNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
return fixer.replaceText(
|
||||
nodeToSurround,
|
||||
`(${sourceCode.getText(nodeToSurround)})`,
|
||||
);
|
||||
},
|
||||
});
|
||||
} else if (style === "inside" && !isFunctionExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrapExpression",
|
||||
fix(fixer) {
|
||||
// The outer call expression will always be wrapped at this point.
|
||||
const isCallExpressionWrapped = isWrappedInAnyParens(node),
|
||||
isFunctionExpressionWrapped = isWrappedInAnyParens(innerNode);
|
||||
|
||||
if (
|
||||
isWrappedInGroupingParens(node) &&
|
||||
!isCalleeOfNewExpression(node)
|
||||
) {
|
||||
/*
|
||||
* Parenthesize the function expression and remove unnecessary grouping parens around the call expression.
|
||||
* Replace the range between the end of the function expression and the end of the call expression.
|
||||
* for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`.
|
||||
*/
|
||||
if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrapInvocation",
|
||||
fix(fixer) {
|
||||
const nodeToSurround = style === "inside" ? innerNode : node;
|
||||
|
||||
const parenAfter =
|
||||
sourceCode.getTokenAfter(node);
|
||||
return fixer.replaceText(nodeToSurround, `(${sourceCode.getText(nodeToSurround)})`);
|
||||
}
|
||||
});
|
||||
} else if (style === "inside" && !isFunctionExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrapExpression",
|
||||
fix(fixer) {
|
||||
|
||||
return fixer.replaceTextRange(
|
||||
[innerNode.range[1], parenAfter.range[1]],
|
||||
`)${sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])}`,
|
||||
);
|
||||
}
|
||||
// The outer call expression will always be wrapped at this point.
|
||||
|
||||
/*
|
||||
* Call expression is wrapped in mandatory parens such as if(), or in necessary grouping parens.
|
||||
* These parens cannot be removed, so just parenthesize the function expression.
|
||||
*/
|
||||
if (isWrappedInGroupingParens(node) && !isCalleeOfNewExpression(node)) {
|
||||
|
||||
return fixer.replaceText(
|
||||
innerNode,
|
||||
`(${sourceCode.getText(innerNode)})`,
|
||||
);
|
||||
},
|
||||
});
|
||||
} else if (style === "outside" && !isCallExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "moveInvocation",
|
||||
fix(fixer) {
|
||||
/*
|
||||
* The inner function expression will always be wrapped at this point.
|
||||
* It's only necessary to replace the range between the end of the function expression
|
||||
* and the call expression. For example, in `(function(foo) {})(bar)`, the range `)(bar)`
|
||||
* should get replaced with `(bar))`.
|
||||
*/
|
||||
const parenAfter =
|
||||
sourceCode.getTokenAfter(innerNode);
|
||||
/*
|
||||
* Parenthesize the function expression and remove unnecessary grouping parens around the call expression.
|
||||
* Replace the range between the end of the function expression and the end of the call expression.
|
||||
* for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`.
|
||||
*/
|
||||
|
||||
return fixer.replaceTextRange(
|
||||
[parenAfter.range[0], node.range[1]],
|
||||
`${sourceCode.getText().slice(parenAfter.range[1], node.range[1])})`,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
const parenAfter = sourceCode.getTokenAfter(node);
|
||||
|
||||
return fixer.replaceTextRange(
|
||||
[innerNode.range[1], parenAfter.range[1]],
|
||||
`)${sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])}`
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call expression is wrapped in mandatory parens such as if(), or in necessary grouping parens.
|
||||
* These parens cannot be removed, so just parenthesize the function expression.
|
||||
*/
|
||||
|
||||
return fixer.replaceText(innerNode, `(${sourceCode.getText(innerNode)})`);
|
||||
}
|
||||
});
|
||||
} else if (style === "outside" && !isCallExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "moveInvocation",
|
||||
fix(fixer) {
|
||||
|
||||
/*
|
||||
* The inner function expression will always be wrapped at this point.
|
||||
* It's only necessary to replace the range between the end of the function expression
|
||||
* and the call expression. For example, in `(function(foo) {})(bar)`, the range `)(bar)`
|
||||
* should get replaced with `(bar))`.
|
||||
*/
|
||||
const parenAfter = sourceCode.getTokenAfter(innerNode);
|
||||
|
||||
return fixer.replaceTextRange(
|
||||
[parenAfter.range[0], node.range[1]],
|
||||
`${sourceCode.getText().slice(parenAfter.range[1], node.range[1])})`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user