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:
+69
-80
@@ -9,9 +9,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const {
|
||||
getStaticPropertyName: getPropertyName,
|
||||
getVariableByName,
|
||||
skipChainExpression,
|
||||
getStaticPropertyName: getPropertyName,
|
||||
getVariableByName,
|
||||
skipChainExpression
|
||||
} = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -24,7 +24,7 @@ const {
|
||||
* @returns {boolean} Whether or not the name is prohibited.
|
||||
*/
|
||||
function isProhibitedIdentifier(name) {
|
||||
return /^(?:alert|confirm|prompt)$/u.test(name);
|
||||
return /^(alert|confirm|prompt)$/u.test(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,16 +34,13 @@ function isProhibitedIdentifier(name) {
|
||||
* @returns {Reference|null} Returns the found reference or null if none were found.
|
||||
*/
|
||||
function findReference(scope, node) {
|
||||
const references = scope.references.filter(
|
||||
reference =>
|
||||
reference.identifier.range[0] === node.range[0] &&
|
||||
reference.identifier.range[1] === node.range[1],
|
||||
);
|
||||
const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] &&
|
||||
reference.identifier.range[1] === node.range[1]);
|
||||
|
||||
if (references.length === 1) {
|
||||
return references[0];
|
||||
}
|
||||
return null;
|
||||
if (references.length === 1) {
|
||||
return references[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,11 +50,9 @@ function findReference(scope, node) {
|
||||
* @returns {boolean} Whether or not the name is shadowed.
|
||||
*/
|
||||
function isShadowed(scope, node) {
|
||||
const reference = findReference(scope, node);
|
||||
const reference = findReference(scope, node);
|
||||
|
||||
return (
|
||||
reference && reference.resolved && reference.resolved.defs.length > 0
|
||||
);
|
||||
return reference && reference.resolved && reference.resolved.defs.length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,83 +62,77 @@ function isShadowed(scope, node) {
|
||||
* @returns {boolean} Whether or not the node is a reference to the global object.
|
||||
*/
|
||||
function isGlobalThisReferenceOrGlobalWindow(scope, node) {
|
||||
if (scope.type === "global" && node.type === "ThisExpression") {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
node.type === "Identifier" &&
|
||||
(node.name === "window" ||
|
||||
(node.name === "globalThis" &&
|
||||
getVariableByName(scope, "globalThis")))
|
||||
) {
|
||||
return !isShadowed(scope, node);
|
||||
}
|
||||
if (scope.type === "global" && node.type === "ThisExpression") {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
node.type === "Identifier" &&
|
||||
(
|
||||
node.name === "window" ||
|
||||
(node.name === "globalThis" && getVariableByName(scope, "globalThis"))
|
||||
)
|
||||
) {
|
||||
return !isShadowed(scope, node);
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow the use of `alert`, `confirm`, and `prompt`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-alert",
|
||||
},
|
||||
docs: {
|
||||
description: "Disallow the use of `alert`, `confirm`, and `prompt`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-alert"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected: "Unexpected {{name}}.",
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
unexpected: "Unexpected {{name}}."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
const callee = skipChainExpression(node.callee),
|
||||
currentScope = sourceCode.getScope(node);
|
||||
return {
|
||||
CallExpression(node) {
|
||||
const callee = skipChainExpression(node.callee),
|
||||
currentScope = sourceCode.getScope(node);
|
||||
|
||||
// without window.
|
||||
if (callee.type === "Identifier") {
|
||||
const name = callee.name;
|
||||
// without window.
|
||||
if (callee.type === "Identifier") {
|
||||
const name = callee.name;
|
||||
|
||||
if (
|
||||
!isShadowed(currentScope, callee) &&
|
||||
isProhibitedIdentifier(callee.name)
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected",
|
||||
data: { name },
|
||||
});
|
||||
}
|
||||
} else if (
|
||||
callee.type === "MemberExpression" &&
|
||||
isGlobalThisReferenceOrGlobalWindow(
|
||||
currentScope,
|
||||
callee.object,
|
||||
)
|
||||
) {
|
||||
const name = getPropertyName(callee);
|
||||
if (!isShadowed(currentScope, callee) && isProhibitedIdentifier(callee.name)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected",
|
||||
data: { name }
|
||||
});
|
||||
}
|
||||
|
||||
if (isProhibitedIdentifier(name)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected",
|
||||
data: { name },
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
} else if (callee.type === "MemberExpression" && isGlobalThisReferenceOrGlobalWindow(currentScope, callee.object)) {
|
||||
const name = getPropertyName(callee);
|
||||
|
||||
if (isProhibitedIdentifier(name)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected",
|
||||
data: { name }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user