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
+71
-142
@@ -21,164 +21,93 @@ const astUtils = require("./utils/ast-utils");
|
||||
* @returns {string} The text that the 1st letter was capitalized.
|
||||
*/
|
||||
function capitalizeFirstLetter(text) {
|
||||
return text[0].toUpperCase() + text.slice(1);
|
||||
return text[0].toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow async functions which have no `await` expression",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/require-await",
|
||||
},
|
||||
docs: {
|
||||
description: "Disallow async functions which have no `await` expression",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/require-await"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
missingAwait: "{{name}} has no 'await' expression.",
|
||||
removeAsync: "Remove 'async'.",
|
||||
},
|
||||
messages: {
|
||||
missingAwait: "{{name}} has no 'await' expression."
|
||||
}
|
||||
},
|
||||
|
||||
hasSuggestions: true,
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
let scopeInfo = null;
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
let scopeInfo = null;
|
||||
/**
|
||||
* Push the scope info object to the stack.
|
||||
* @returns {void}
|
||||
*/
|
||||
function enterFunction() {
|
||||
scopeInfo = {
|
||||
upper: scopeInfo,
|
||||
hasAwait: false
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Push the scope info object to the stack.
|
||||
* @returns {void}
|
||||
*/
|
||||
function enterFunction() {
|
||||
scopeInfo = {
|
||||
upper: scopeInfo,
|
||||
hasAwait: false,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Pop the top scope info object from the stack.
|
||||
* Also, it reports the function if needed.
|
||||
* @param {ASTNode} node The node to report.
|
||||
* @returns {void}
|
||||
*/
|
||||
function exitFunction(node) {
|
||||
if (!node.generator && node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
||||
messageId: "missingAwait",
|
||||
data: {
|
||||
name: capitalizeFirstLetter(
|
||||
astUtils.getFunctionNameWithKind(node)
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop the top scope info object from the stack.
|
||||
* Also, it reports the function if needed.
|
||||
* @param {ASTNode} node The node to report.
|
||||
* @returns {void}
|
||||
*/
|
||||
function exitFunction(node) {
|
||||
if (
|
||||
!node.generator &&
|
||||
node.async &&
|
||||
!scopeInfo.hasAwait &&
|
||||
!astUtils.isEmptyFunction(node)
|
||||
) {
|
||||
/*
|
||||
* If the function belongs to a method definition or
|
||||
* property, then the function's range may not include the
|
||||
* `async` keyword and we should look at the parent instead.
|
||||
*/
|
||||
const nodeWithAsyncKeyword =
|
||||
(node.parent.type === "MethodDefinition" &&
|
||||
node.parent.value === node) ||
|
||||
(node.parent.type === "Property" &&
|
||||
node.parent.method &&
|
||||
node.parent.value === node)
|
||||
? node.parent
|
||||
: node;
|
||||
scopeInfo = scopeInfo.upper;
|
||||
}
|
||||
|
||||
const asyncToken = sourceCode.getFirstToken(
|
||||
nodeWithAsyncKeyword,
|
||||
token => token.value === "async",
|
||||
);
|
||||
const asyncRange = [
|
||||
asyncToken.range[0],
|
||||
sourceCode.getTokenAfter(asyncToken, {
|
||||
includeComments: true,
|
||||
}).range[0],
|
||||
];
|
||||
return {
|
||||
FunctionDeclaration: enterFunction,
|
||||
FunctionExpression: enterFunction,
|
||||
ArrowFunctionExpression: enterFunction,
|
||||
"FunctionDeclaration:exit": exitFunction,
|
||||
"FunctionExpression:exit": exitFunction,
|
||||
"ArrowFunctionExpression:exit": exitFunction,
|
||||
|
||||
/*
|
||||
* Removing the `async` keyword can cause parsing errors if the current
|
||||
* statement is relying on automatic semicolon insertion. If ASI is currently
|
||||
* being used, then we should replace the `async` keyword with a semicolon.
|
||||
*/
|
||||
const nextToken = sourceCode.getTokenAfter(asyncToken);
|
||||
const addSemiColon =
|
||||
nextToken.type === "Punctuator" &&
|
||||
(nextToken.value === "[" || nextToken.value === "(") &&
|
||||
(nodeWithAsyncKeyword.type === "MethodDefinition" ||
|
||||
astUtils.isStartOfExpressionStatement(
|
||||
nodeWithAsyncKeyword,
|
||||
)) &&
|
||||
astUtils.needsPrecedingSemicolon(
|
||||
sourceCode,
|
||||
nodeWithAsyncKeyword,
|
||||
);
|
||||
AwaitExpression() {
|
||||
if (!scopeInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
||||
messageId: "missingAwait",
|
||||
data: {
|
||||
name: capitalizeFirstLetter(
|
||||
astUtils.getFunctionNameWithKind(node),
|
||||
),
|
||||
},
|
||||
suggest: [
|
||||
{
|
||||
messageId: "removeAsync",
|
||||
fix: fixer =>
|
||||
fixer.replaceTextRange(
|
||||
asyncRange,
|
||||
addSemiColon ? ";" : "",
|
||||
),
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
scopeInfo.hasAwait = true;
|
||||
},
|
||||
ForOfStatement(node) {
|
||||
if (!scopeInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
scopeInfo = scopeInfo.upper;
|
||||
}
|
||||
|
||||
return {
|
||||
FunctionDeclaration: enterFunction,
|
||||
FunctionExpression: enterFunction,
|
||||
ArrowFunctionExpression: enterFunction,
|
||||
"FunctionDeclaration:exit": exitFunction,
|
||||
"FunctionExpression:exit": exitFunction,
|
||||
"ArrowFunctionExpression:exit": exitFunction,
|
||||
|
||||
AwaitExpression() {
|
||||
if (!scopeInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
scopeInfo.hasAwait = true;
|
||||
},
|
||||
ForOfStatement(node) {
|
||||
if (!scopeInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.await) {
|
||||
scopeInfo.hasAwait = true;
|
||||
}
|
||||
},
|
||||
VariableDeclaration(node) {
|
||||
if (!scopeInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.kind === "await using") {
|
||||
scopeInfo.hasAwait = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
if (node.await) {
|
||||
scopeInfo.hasAwait = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user