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:
+266
-322
@@ -17,7 +17,7 @@ const astUtils = require("./utils/ast-utils");
|
||||
* @returns {boolean} `true` if the variable is a function name.
|
||||
*/
|
||||
function isFunctionName(variable) {
|
||||
return variable && variable.defs[0].type === "FunctionName";
|
||||
return variable && variable.defs[0].type === "FunctionName";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ function isFunctionName(variable) {
|
||||
* @returns {boolean} `true` if the node is the specific value.
|
||||
*/
|
||||
function checkMetaProperty(node, metaName, propertyName) {
|
||||
return node.meta.name === metaName && node.property.name === propertyName;
|
||||
return node.meta.name === metaName && node.property.name === propertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,23 +37,24 @@ function checkMetaProperty(node, metaName, propertyName) {
|
||||
* @returns {eslint-scope.Variable} The found variable object.
|
||||
*/
|
||||
function getVariableOfArguments(scope) {
|
||||
const variables = scope.variables;
|
||||
const variables = scope.variables;
|
||||
|
||||
for (let i = 0; i < variables.length; ++i) {
|
||||
const variable = variables[i];
|
||||
for (let i = 0; i < variables.length; ++i) {
|
||||
const variable = variables[i];
|
||||
|
||||
if (variable.name === "arguments") {
|
||||
/*
|
||||
* If there was a parameter which is named "arguments", the
|
||||
* implicit "arguments" is not defined.
|
||||
* So does fast return with null.
|
||||
*/
|
||||
return variable.identifiers.length === 0 ? variable : null;
|
||||
}
|
||||
}
|
||||
if (variable.name === "arguments") {
|
||||
|
||||
/* c8 ignore next */
|
||||
return null;
|
||||
/*
|
||||
* If there was a parameter which is named "arguments", the
|
||||
* implicit "arguments" is not defined.
|
||||
* So does fast return with null.
|
||||
*/
|
||||
return (variable.identifiers.length === 0) ? variable : null;
|
||||
}
|
||||
}
|
||||
|
||||
/* c8 ignore next */
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,68 +66,68 @@ function getVariableOfArguments(scope) {
|
||||
* {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`.
|
||||
*/
|
||||
function getCallbackInfo(node) {
|
||||
const retv = { isCallback: false, isLexicalThis: false };
|
||||
let currentNode = node;
|
||||
let parent = node.parent;
|
||||
let bound = false;
|
||||
const retv = { isCallback: false, isLexicalThis: false };
|
||||
let currentNode = node;
|
||||
let parent = node.parent;
|
||||
let bound = false;
|
||||
|
||||
while (currentNode) {
|
||||
switch (parent.type) {
|
||||
// Checks parents recursively.
|
||||
while (currentNode) {
|
||||
switch (parent.type) {
|
||||
|
||||
case "LogicalExpression":
|
||||
case "ChainExpression":
|
||||
case "ConditionalExpression":
|
||||
break;
|
||||
// Checks parents recursively.
|
||||
|
||||
// Checks whether the parent node is `.bind(this)` call.
|
||||
case "MemberExpression":
|
||||
if (
|
||||
parent.object === currentNode &&
|
||||
!parent.property.computed &&
|
||||
parent.property.type === "Identifier" &&
|
||||
parent.property.name === "bind"
|
||||
) {
|
||||
const maybeCallee =
|
||||
parent.parent.type === "ChainExpression"
|
||||
? parent.parent
|
||||
: parent;
|
||||
case "LogicalExpression":
|
||||
case "ChainExpression":
|
||||
case "ConditionalExpression":
|
||||
break;
|
||||
|
||||
if (astUtils.isCallee(maybeCallee)) {
|
||||
if (!bound) {
|
||||
bound = true; // Use only the first `.bind()` to make `isLexicalThis` value.
|
||||
retv.isLexicalThis =
|
||||
maybeCallee.parent.arguments.length === 1 &&
|
||||
maybeCallee.parent.arguments[0].type ===
|
||||
"ThisExpression";
|
||||
}
|
||||
parent = maybeCallee.parent;
|
||||
} else {
|
||||
return retv;
|
||||
}
|
||||
} else {
|
||||
return retv;
|
||||
}
|
||||
break;
|
||||
// Checks whether the parent node is `.bind(this)` call.
|
||||
case "MemberExpression":
|
||||
if (
|
||||
parent.object === currentNode &&
|
||||
!parent.property.computed &&
|
||||
parent.property.type === "Identifier" &&
|
||||
parent.property.name === "bind"
|
||||
) {
|
||||
const maybeCallee = parent.parent.type === "ChainExpression"
|
||||
? parent.parent
|
||||
: parent;
|
||||
|
||||
// Checks whether the node is a callback.
|
||||
case "CallExpression":
|
||||
case "NewExpression":
|
||||
if (parent.callee !== currentNode) {
|
||||
retv.isCallback = true;
|
||||
}
|
||||
return retv;
|
||||
if (astUtils.isCallee(maybeCallee)) {
|
||||
if (!bound) {
|
||||
bound = true; // Use only the first `.bind()` to make `isLexicalThis` value.
|
||||
retv.isLexicalThis = (
|
||||
maybeCallee.parent.arguments.length === 1 &&
|
||||
maybeCallee.parent.arguments[0].type === "ThisExpression"
|
||||
);
|
||||
}
|
||||
parent = maybeCallee.parent;
|
||||
} else {
|
||||
return retv;
|
||||
}
|
||||
} else {
|
||||
return retv;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return retv;
|
||||
}
|
||||
// Checks whether the node is a callback.
|
||||
case "CallExpression":
|
||||
case "NewExpression":
|
||||
if (parent.callee !== currentNode) {
|
||||
retv.isCallback = true;
|
||||
}
|
||||
return retv;
|
||||
|
||||
currentNode = parent;
|
||||
parent = parent.parent;
|
||||
}
|
||||
default:
|
||||
return retv;
|
||||
}
|
||||
|
||||
/* c8 ignore next */
|
||||
throw new Error("unreachable");
|
||||
currentNode = parent;
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
/* c8 ignore next */
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,301 +138,244 @@ function getCallbackInfo(node) {
|
||||
* @returns {boolean} `true` if the list of parameters contains any duplicates
|
||||
*/
|
||||
function hasDuplicateParams(paramsList) {
|
||||
return (
|
||||
paramsList.every(param => param.type === "Identifier") &&
|
||||
paramsList.length !== new Set(paramsList.map(param => param.name)).size
|
||||
);
|
||||
return paramsList.every(param => param.type === "Identifier") && paramsList.length !== new Set(paramsList.map(param => param.name)).size;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
dialects: ["javascript", "typescript"],
|
||||
language: "javascript",
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: [
|
||||
{ allowNamedFunctions: false, allowUnboundThis: true },
|
||||
],
|
||||
docs: {
|
||||
description: "Require using arrow functions for callbacks",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/prefer-arrow-callback"
|
||||
},
|
||||
|
||||
docs: {
|
||||
description: "Require using arrow functions for callbacks",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/prefer-arrow-callback",
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowNamedFunctions: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
allowUnboundThis: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowNamedFunctions: {
|
||||
type: "boolean",
|
||||
},
|
||||
allowUnboundThis: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: "code",
|
||||
|
||||
fixable: "code",
|
||||
messages: {
|
||||
preferArrowCallback: "Unexpected function expression."
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
preferArrowCallback: "Unexpected function expression.",
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const options = context.options[0] || {};
|
||||
|
||||
create(context) {
|
||||
const [{ allowNamedFunctions, allowUnboundThis }] = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
const allowUnboundThis = options.allowUnboundThis !== false; // default to true
|
||||
const allowNamedFunctions = options.allowNamedFunctions;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/*
|
||||
* {Array<{this: boolean, super: boolean, meta: boolean}>}
|
||||
* - this - A flag which shows there are one or more ThisExpression.
|
||||
* - super - A flag which shows there are one or more Super.
|
||||
* - meta - A flag which shows there are one or more MethProperty.
|
||||
*/
|
||||
let stack = [];
|
||||
/*
|
||||
* {Array<{this: boolean, super: boolean, meta: boolean}>}
|
||||
* - this - A flag which shows there are one or more ThisExpression.
|
||||
* - super - A flag which shows there are one or more Super.
|
||||
* - meta - A flag which shows there are one or more MethProperty.
|
||||
*/
|
||||
let stack = [];
|
||||
|
||||
/**
|
||||
* Pushes new function scope with all `false` flags.
|
||||
* @returns {void}
|
||||
*/
|
||||
function enterScope() {
|
||||
stack.push({ this: false, super: false, meta: false });
|
||||
}
|
||||
/**
|
||||
* Pushes new function scope with all `false` flags.
|
||||
* @returns {void}
|
||||
*/
|
||||
function enterScope() {
|
||||
stack.push({ this: false, super: false, meta: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops a function scope from the stack.
|
||||
* @returns {{this: boolean, super: boolean, meta: boolean}} The information of the last scope.
|
||||
*/
|
||||
function exitScope() {
|
||||
return stack.pop();
|
||||
}
|
||||
/**
|
||||
* Pops a function scope from the stack.
|
||||
* @returns {{this: boolean, super: boolean, meta: boolean}} The information of the last scope.
|
||||
*/
|
||||
function exitScope() {
|
||||
return stack.pop();
|
||||
}
|
||||
|
||||
return {
|
||||
// Reset internal state.
|
||||
Program() {
|
||||
stack = [];
|
||||
},
|
||||
return {
|
||||
|
||||
// If there are below, it cannot replace with arrow functions merely.
|
||||
ThisExpression() {
|
||||
const info = stack.at(-1);
|
||||
// Reset internal state.
|
||||
Program() {
|
||||
stack = [];
|
||||
},
|
||||
|
||||
if (info) {
|
||||
info.this = true;
|
||||
}
|
||||
},
|
||||
// If there are below, it cannot replace with arrow functions merely.
|
||||
ThisExpression() {
|
||||
const info = stack[stack.length - 1];
|
||||
|
||||
Super() {
|
||||
const info = stack.at(-1);
|
||||
if (info) {
|
||||
info.this = true;
|
||||
}
|
||||
},
|
||||
|
||||
if (info) {
|
||||
info.super = true;
|
||||
}
|
||||
},
|
||||
Super() {
|
||||
const info = stack[stack.length - 1];
|
||||
|
||||
MetaProperty(node) {
|
||||
const info = stack.at(-1);
|
||||
if (info) {
|
||||
info.super = true;
|
||||
}
|
||||
},
|
||||
|
||||
if (info && checkMetaProperty(node, "new", "target")) {
|
||||
info.meta = true;
|
||||
}
|
||||
},
|
||||
MetaProperty(node) {
|
||||
const info = stack[stack.length - 1];
|
||||
|
||||
// To skip nested scopes.
|
||||
FunctionDeclaration: enterScope,
|
||||
"FunctionDeclaration:exit": exitScope,
|
||||
if (info && checkMetaProperty(node, "new", "target")) {
|
||||
info.meta = true;
|
||||
}
|
||||
},
|
||||
|
||||
// Main.
|
||||
FunctionExpression: enterScope,
|
||||
"FunctionExpression:exit"(node) {
|
||||
const scopeInfo = exitScope();
|
||||
// To skip nested scopes.
|
||||
FunctionDeclaration: enterScope,
|
||||
"FunctionDeclaration:exit": exitScope,
|
||||
|
||||
// Skip named function expressions
|
||||
if (allowNamedFunctions && node.id && node.id.name) {
|
||||
return;
|
||||
}
|
||||
// Main.
|
||||
FunctionExpression: enterScope,
|
||||
"FunctionExpression:exit"(node) {
|
||||
const scopeInfo = exitScope();
|
||||
|
||||
// Skip generators.
|
||||
if (node.generator) {
|
||||
return;
|
||||
}
|
||||
// Skip named function expressions
|
||||
if (allowNamedFunctions && node.id && node.id.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip recursive functions.
|
||||
const nameVar = sourceCode.getDeclaredVariables(node)[0];
|
||||
// Skip generators.
|
||||
if (node.generator) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFunctionName(nameVar) && nameVar.references.length > 0) {
|
||||
return;
|
||||
}
|
||||
// Skip recursive functions.
|
||||
const nameVar = sourceCode.getDeclaredVariables(node)[0];
|
||||
|
||||
// Skip if it's using arguments.
|
||||
const variable = getVariableOfArguments(
|
||||
sourceCode.getScope(node),
|
||||
);
|
||||
if (isFunctionName(nameVar) && nameVar.references.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (variable && variable.references.length > 0) {
|
||||
return;
|
||||
}
|
||||
// Skip if it's using arguments.
|
||||
const variable = getVariableOfArguments(sourceCode.getScope(node));
|
||||
|
||||
// Reports if it's a callback which can replace with arrows.
|
||||
const callbackInfo = getCallbackInfo(node);
|
||||
if (variable && variable.references.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
callbackInfo.isCallback &&
|
||||
(!allowUnboundThis ||
|
||||
!scopeInfo.this ||
|
||||
callbackInfo.isLexicalThis) &&
|
||||
!scopeInfo.super &&
|
||||
!scopeInfo.meta
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "preferArrowCallback",
|
||||
*fix(fixer) {
|
||||
if (
|
||||
(!callbackInfo.isLexicalThis &&
|
||||
scopeInfo.this) ||
|
||||
hasDuplicateParams(node.params)
|
||||
) {
|
||||
/*
|
||||
* If the callback function does not have .bind(this) and contains a reference to `this`, there
|
||||
* is no way to determine what `this` should be, so don't perform any fixes.
|
||||
* If the callback function has duplicates in its list of parameters (possible in sloppy mode),
|
||||
* don't replace it with an arrow function, because this is a SyntaxError with arrow functions.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
// Reports if it's a callback which can replace with arrows.
|
||||
const callbackInfo = getCallbackInfo(node);
|
||||
|
||||
if (
|
||||
node.params.length &&
|
||||
node.params[0].name === "this"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (callbackInfo.isCallback &&
|
||||
(!allowUnboundThis || !scopeInfo.this || callbackInfo.isLexicalThis) &&
|
||||
!scopeInfo.super &&
|
||||
!scopeInfo.meta
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "preferArrowCallback",
|
||||
*fix(fixer) {
|
||||
if ((!callbackInfo.isLexicalThis && scopeInfo.this) || hasDuplicateParams(node.params)) {
|
||||
|
||||
// Remove `.bind(this)` if exists.
|
||||
if (callbackInfo.isLexicalThis) {
|
||||
const memberNode = node.parent;
|
||||
/*
|
||||
* If the callback function does not have .bind(this) and contains a reference to `this`, there
|
||||
* is no way to determine what `this` should be, so don't perform any fixes.
|
||||
* If the callback function has duplicates in its list of parameters (possible in sloppy mode),
|
||||
* don't replace it with an arrow function, because this is a SyntaxError with arrow functions.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If `.bind(this)` exists but the parent is not `.bind(this)`, don't remove it automatically.
|
||||
* E.g. `(foo || function(){}).bind(this)`
|
||||
*/
|
||||
if (memberNode.type !== "MemberExpression") {
|
||||
return;
|
||||
}
|
||||
// Remove `.bind(this)` if exists.
|
||||
if (callbackInfo.isLexicalThis) {
|
||||
const memberNode = node.parent;
|
||||
|
||||
const callNode = memberNode.parent;
|
||||
const firstTokenToRemove =
|
||||
sourceCode.getTokenAfter(
|
||||
memberNode.object,
|
||||
astUtils.isNotClosingParenToken,
|
||||
);
|
||||
const lastTokenToRemove =
|
||||
sourceCode.getLastToken(callNode);
|
||||
/*
|
||||
* If `.bind(this)` exists but the parent is not `.bind(this)`, don't remove it automatically.
|
||||
* E.g. `(foo || function(){}).bind(this)`
|
||||
*/
|
||||
if (memberNode.type !== "MemberExpression") {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the member expression is parenthesized, don't remove the right paren.
|
||||
* E.g. `(function(){}.bind)(this)`
|
||||
* ^^^^^^^^^^^^
|
||||
*/
|
||||
if (
|
||||
astUtils.isParenthesised(
|
||||
sourceCode,
|
||||
memberNode,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const callNode = memberNode.parent;
|
||||
const firstTokenToRemove = sourceCode.getTokenAfter(memberNode.object, astUtils.isNotClosingParenToken);
|
||||
const lastTokenToRemove = sourceCode.getLastToken(callNode);
|
||||
|
||||
// If comments exist in the `.bind(this)`, don't remove those.
|
||||
if (
|
||||
sourceCode.commentsExistBetween(
|
||||
firstTokenToRemove,
|
||||
lastTokenToRemove,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* If the member expression is parenthesized, don't remove the right paren.
|
||||
* E.g. `(function(){}.bind)(this)`
|
||||
* ^^^^^^^^^^^^
|
||||
*/
|
||||
if (astUtils.isParenthesised(sourceCode, memberNode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield fixer.removeRange([
|
||||
firstTokenToRemove.range[0],
|
||||
lastTokenToRemove.range[1],
|
||||
]);
|
||||
}
|
||||
// If comments exist in the `.bind(this)`, don't remove those.
|
||||
if (sourceCode.commentsExistBetween(firstTokenToRemove, lastTokenToRemove)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert the function expression to an arrow function.
|
||||
const functionToken = sourceCode.getFirstToken(
|
||||
node,
|
||||
node.async ? 1 : 0,
|
||||
);
|
||||
const leftParenToken = sourceCode.getTokenAfter(
|
||||
functionToken,
|
||||
astUtils.isOpeningParenToken,
|
||||
);
|
||||
const tokenBeforeBody = sourceCode.getTokenBefore(
|
||||
node.body,
|
||||
);
|
||||
yield fixer.removeRange([firstTokenToRemove.range[0], lastTokenToRemove.range[1]]);
|
||||
}
|
||||
|
||||
if (
|
||||
sourceCode.commentsExistBetween(
|
||||
functionToken,
|
||||
leftParenToken,
|
||||
)
|
||||
) {
|
||||
// Remove only extra tokens to keep comments.
|
||||
yield fixer.remove(functionToken);
|
||||
if (node.id) {
|
||||
yield fixer.remove(node.id);
|
||||
}
|
||||
} else {
|
||||
// Remove extra tokens and spaces.
|
||||
yield fixer.removeRange([
|
||||
functionToken.range[0],
|
||||
leftParenToken.range[0],
|
||||
]);
|
||||
}
|
||||
yield fixer.insertTextAfter(tokenBeforeBody, " =>");
|
||||
// Convert the function expression to an arrow function.
|
||||
const functionToken = sourceCode.getFirstToken(node, node.async ? 1 : 0);
|
||||
const leftParenToken = sourceCode.getTokenAfter(functionToken, astUtils.isOpeningParenToken);
|
||||
const tokenBeforeBody = sourceCode.getTokenBefore(node.body);
|
||||
|
||||
// Get the node that will become the new arrow function.
|
||||
let replacedNode = callbackInfo.isLexicalThis
|
||||
? node.parent.parent
|
||||
: node;
|
||||
if (sourceCode.commentsExistBetween(functionToken, leftParenToken)) {
|
||||
|
||||
if (replacedNode.type === "ChainExpression") {
|
||||
replacedNode = replacedNode.parent;
|
||||
}
|
||||
// Remove only extra tokens to keep comments.
|
||||
yield fixer.remove(functionToken);
|
||||
if (node.id) {
|
||||
yield fixer.remove(node.id);
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
* If the replaced node is part of a BinaryExpression, LogicalExpression, or MemberExpression, then
|
||||
* the arrow function needs to be parenthesized, because `foo || () => {}` is invalid syntax even
|
||||
* though `foo || function() {}` is valid.
|
||||
*/
|
||||
if (
|
||||
replacedNode.parent.type !== "CallExpression" &&
|
||||
replacedNode.parent.type !==
|
||||
"ConditionalExpression" &&
|
||||
!astUtils.isParenthesised(
|
||||
sourceCode,
|
||||
replacedNode,
|
||||
) &&
|
||||
!astUtils.isParenthesised(sourceCode, node)
|
||||
) {
|
||||
yield fixer.insertTextBefore(replacedNode, "(");
|
||||
yield fixer.insertTextAfter(replacedNode, ")");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
// Remove extra tokens and spaces.
|
||||
yield fixer.removeRange([functionToken.range[0], leftParenToken.range[0]]);
|
||||
}
|
||||
yield fixer.insertTextAfter(tokenBeforeBody, " =>");
|
||||
|
||||
// Get the node that will become the new arrow function.
|
||||
let replacedNode = callbackInfo.isLexicalThis ? node.parent.parent : node;
|
||||
|
||||
if (replacedNode.type === "ChainExpression") {
|
||||
replacedNode = replacedNode.parent;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the replaced node is part of a BinaryExpression, LogicalExpression, or MemberExpression, then
|
||||
* the arrow function needs to be parenthesized, because `foo || () => {}` is invalid syntax even
|
||||
* though `foo || function() {}` is valid.
|
||||
*/
|
||||
if (
|
||||
replacedNode.parent.type !== "CallExpression" &&
|
||||
replacedNode.parent.type !== "ConditionalExpression" &&
|
||||
!astUtils.isParenthesised(sourceCode, replacedNode) &&
|
||||
!astUtils.isParenthesised(sourceCode, node)
|
||||
) {
|
||||
yield fixer.insertTextBefore(replacedNode, "(");
|
||||
yield fixer.insertTextAfter(replacedNode, ")");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user