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:
+75
-102
@@ -16,114 +16,87 @@ const { upperCaseFirst } = require("../shared/string-utils");
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
dialects: ["typescript", "javascript"],
|
||||
language: "javascript",
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce a maximum number of parameters in function definitions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/max-params",
|
||||
},
|
||||
docs: {
|
||||
description: "Enforce a maximum number of parameters in function definitions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/max-params"
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
maximum: {
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
},
|
||||
max: {
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
},
|
||||
countVoidThis: {
|
||||
type: "boolean",
|
||||
description:
|
||||
"Whether to count a `this` declaration when the type is `void`.",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
exceed: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}.",
|
||||
},
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
maximum: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
max: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
exceed: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0];
|
||||
let numParams = 3;
|
||||
let countVoidThis = false;
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0];
|
||||
let numParams = 3;
|
||||
|
||||
if (typeof option === "object") {
|
||||
if (
|
||||
Object.hasOwn(option, "maximum") ||
|
||||
Object.hasOwn(option, "max")
|
||||
) {
|
||||
numParams = option.maximum || option.max;
|
||||
}
|
||||
countVoidThis = option.countVoidThis;
|
||||
}
|
||||
if (typeof option === "number") {
|
||||
numParams = option;
|
||||
}
|
||||
if (
|
||||
typeof option === "object" &&
|
||||
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
||||
) {
|
||||
numParams = option.maximum || option.max;
|
||||
}
|
||||
if (typeof option === "number") {
|
||||
numParams = option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a function to see if it has too many parameters.
|
||||
* @param {ASTNode} node The node to check.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkFunction(node) {
|
||||
const hasVoidThisParam =
|
||||
node.params.length > 0 &&
|
||||
node.params[0].type === "Identifier" &&
|
||||
node.params[0].name === "this" &&
|
||||
node.params[0].typeAnnotation?.typeAnnotation.type ===
|
||||
"TSVoidKeyword";
|
||||
/**
|
||||
* Checks a function to see if it has too many parameters.
|
||||
* @param {ASTNode} node The node to check.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkFunction(node) {
|
||||
if (node.params.length > numParams) {
|
||||
context.report({
|
||||
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
||||
node,
|
||||
messageId: "exceed",
|
||||
data: {
|
||||
name: upperCaseFirst(astUtils.getFunctionNameWithKind(node)),
|
||||
count: node.params.length,
|
||||
max: numParams
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const effectiveParamCount =
|
||||
hasVoidThisParam && !countVoidThis
|
||||
? node.params.length - 1
|
||||
: node.params.length;
|
||||
return {
|
||||
FunctionDeclaration: checkFunction,
|
||||
ArrowFunctionExpression: checkFunction,
|
||||
FunctionExpression: checkFunction
|
||||
};
|
||||
|
||||
if (effectiveParamCount > numParams) {
|
||||
context.report({
|
||||
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
||||
node,
|
||||
messageId: "exceed",
|
||||
data: {
|
||||
name: upperCaseFirst(
|
||||
astUtils.getFunctionNameWithKind(node),
|
||||
),
|
||||
count: effectiveParamCount,
|
||||
max: numParams,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
FunctionDeclaration: checkFunction,
|
||||
ArrowFunctionExpression: checkFunction,
|
||||
FunctionExpression: checkFunction,
|
||||
TSDeclareFunction: checkFunction,
|
||||
TSFunctionType: checkFunction,
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user