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:
+65
-102
@@ -15,17 +15,8 @@ const astUtils = require("./utils/ast-utils");
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const validParent = new Set([
|
||||
"Program",
|
||||
"StaticBlock",
|
||||
"ExportNamedDeclaration",
|
||||
"ExportDefaultDeclaration",
|
||||
]);
|
||||
const validBlockStatementParent = new Set([
|
||||
"FunctionDeclaration",
|
||||
"FunctionExpression",
|
||||
"ArrowFunctionExpression",
|
||||
]);
|
||||
const validParent = new Set(["Program", "StaticBlock", "ExportNamedDeclaration", "ExportDefaultDeclaration"]);
|
||||
const validBlockStatementParent = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
|
||||
|
||||
/**
|
||||
* Finds the nearest enclosing context where this rule allows declarations and returns its description.
|
||||
@@ -33,115 +24,87 @@ const validBlockStatementParent = new Set([
|
||||
* @returns {string} Description. One of "program", "function body", "class static block body".
|
||||
*/
|
||||
function getAllowedBodyDescription(node) {
|
||||
let { parent } = node;
|
||||
let { parent } = node;
|
||||
|
||||
while (parent) {
|
||||
if (parent.type === "StaticBlock") {
|
||||
return "class static block body";
|
||||
}
|
||||
while (parent) {
|
||||
|
||||
if (astUtils.isFunction(parent)) {
|
||||
return "function body";
|
||||
}
|
||||
if (parent.type === "StaticBlock") {
|
||||
return "class static block body";
|
||||
}
|
||||
|
||||
({ parent } = parent);
|
||||
}
|
||||
if (astUtils.isFunction(parent)) {
|
||||
return "function body";
|
||||
}
|
||||
|
||||
return "program";
|
||||
({ parent } = parent);
|
||||
}
|
||||
|
||||
return "program";
|
||||
}
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
defaultOptions: ["functions", { blockScopedFunctions: "allow" }],
|
||||
docs: {
|
||||
description: "Disallow variable or `function` declarations in nested blocks",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-inner-declarations"
|
||||
},
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow variable or `function` declarations in nested blocks",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-inner-declarations",
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
enum: ["functions", "both"]
|
||||
}
|
||||
],
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["functions", "both"],
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
blockScopedFunctions: {
|
||||
enum: ["allow", "disallow"],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
moveDeclToRoot: "Move {{type}} declaration to {{body}} root."
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
moveDeclToRoot: "Move {{type}} declaration to {{body}} root.",
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
|
||||
create(context) {
|
||||
const both = context.options[0] === "both";
|
||||
const { blockScopedFunctions } = context.options[1];
|
||||
/**
|
||||
* Ensure that a given node is at a program or function body's root.
|
||||
* @param {ASTNode} node Declaration node to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function check(node) {
|
||||
const parent = node.parent;
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
const ecmaVersion = context.languageOptions.ecmaVersion;
|
||||
if (
|
||||
parent.type === "BlockStatement" && validBlockStatementParent.has(parent.parent.type)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a given node is at a program or function body's root.
|
||||
* @param {ASTNode} node Declaration node to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function check(node) {
|
||||
const parent = node.parent;
|
||||
if (validParent.has(parent.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
parent.type === "BlockStatement" &&
|
||||
validBlockStatementParent.has(parent.parent.type)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: "moveDeclToRoot",
|
||||
data: {
|
||||
type: (node.type === "FunctionDeclaration" ? "function" : "variable"),
|
||||
body: getAllowedBodyDescription(node)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (validParent.has(parent.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: "moveDeclToRoot",
|
||||
data: {
|
||||
type:
|
||||
node.type === "FunctionDeclaration"
|
||||
? "function"
|
||||
: "variable",
|
||||
body: getAllowedBodyDescription(node),
|
||||
},
|
||||
});
|
||||
}
|
||||
return {
|
||||
|
||||
return {
|
||||
FunctionDeclaration(node) {
|
||||
const isInStrictCode = sourceCode.getScope(node).upper.isStrict;
|
||||
FunctionDeclaration: check,
|
||||
VariableDeclaration(node) {
|
||||
if (context.options[0] === "both" && node.kind === "var") {
|
||||
check(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
blockScopedFunctions === "allow" &&
|
||||
ecmaVersion >= 2015 &&
|
||||
isInStrictCode
|
||||
) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
check(node);
|
||||
},
|
||||
VariableDeclaration(node) {
|
||||
if (both && node.kind === "var") {
|
||||
check(node);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user