Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_this.handleBindingName(node.variableDeclaration.name, {
canBeConst: false,
isBlockScoped: true,
});
}
}
else if (node.kind === ts.SyntaxKind.Parameter) {
if (node.parent.kind !== ts.SyntaxKind.IndexSignature) {
_this.handleBindingName(node.name, {
canBeConst: false,
isBlockScoped: true,
});
}
}
else if (utils.isPostfixUnaryExpression(node) ||
(utils.isPrefixUnaryExpression(node) &&
(node.operator === ts.SyntaxKind.PlusPlusToken ||
node.operator === ts.SyntaxKind.MinusMinusToken))) {
if (utils.isIdentifier(node.operand)) {
_this.scope.reassigned.add(node.operand.text);
}
}
else if (utils.isBinaryExpression(node) &&
utils.isAssignmentKind(node.operatorToken.kind)) {
_this.handleExpression(node.left);
}
if (boundary !== 0 /* None */) {
ts.forEachChild(node, cb);
_this.onScopeEnd(savedScope);
_this.scope = savedScope;
}
else {
function isUnaryPrefixOrPostfix(node: ts.Node): boolean {
const { parent } = node;
return (
tsutils.isPrefixUnaryExpression(parent) ||
tsutils.isPostfixUnaryExpression(parent)
);
}
if (node.initializer) {
cb(node.initializer);
}
if (node.condition) {
cb(node.condition);
}
}
else {
ts.forEachChild(node, cb);
}
return;
}
if (tsutils.isPostfixUnaryExpression(node)) {
validateUnaryExpression(node);
}
else if (tsutils.isPrefixUnaryExpression(node)) {
validateUnaryExpression(node);
}
return ts.forEachChild(node, cb);
}
return ts.forEachChild(ctx.sourceFile, cb);
if ((node as ts.CatchClause).variableDeclaration !== undefined) {
this.handleBindingName((node as ts.CatchClause).variableDeclaration!.name, {
canBeConst: false,
isBlockScoped: true,
});
}
} else if (node.kind === ts.SyntaxKind.Parameter) {
if (node.parent.kind !== ts.SyntaxKind.IndexSignature) {
this.handleBindingName((node as ts.ParameterDeclaration).name, {
canBeConst: false,
isBlockScoped: true,
});
}
} else if (
utils.isPostfixUnaryExpression(node) ||
(utils.isPrefixUnaryExpression(node) &&
(node.operator === ts.SyntaxKind.PlusPlusToken ||
node.operator === ts.SyntaxKind.MinusMinusToken))
) {
if (utils.isIdentifier(node.operand)) {
this.scope.reassigned.add(node.operand.text);
}
} else if (
utils.isBinaryExpression(node) &&
utils.isAssignmentKind(node.operatorToken.kind)
) {
this.handleExpression(node.left);
}
if (boundary !== utils.ScopeBoundary.None) {
ts.forEachChild(node, cb);
this.onScopeEnd(savedScope);
function isNumberLike(node: ts.Node): boolean {
if (tsutils.isPrefixUnaryExpression(node)) {
return tsutils.isNumericLiteral(node.operand) && node.operator === ts.SyntaxKind.MinusToken;
}
return tsutils.isNumericLiteral(node);
}
var cb = function (node) {
if (node.kind === ts.SyntaxKind.NumericLiteral) {
return _this.checkNumericLiteral(node, node.text);
}
if (tsutils_1.isPrefixUnaryExpression(node) &&
node.operator === ts.SyntaxKind.MinusToken &&
node.operand.kind === ts.SyntaxKind.NumericLiteral) {
return _this.checkNumericLiteral(node, "-" + node.operand.text);
}
return ts.forEachChild(node, cb);
};
return ts.forEachChild(sourceFile, cb);
export function isNumeric(node: ts.Expression) {
while (
isPrefixUnaryExpression(node) &&
(node.operator === ts.SyntaxKind.PlusToken || node.operator === ts.SyntaxKind.MinusToken)
) {
node = node.operand;
}
return (
node.kind === ts.SyntaxKind.NumericLiteral ||
(isIdentifier(node) && (node.text === "NaN" || node.text === "Infinity"))
);
}
function isNumberLike(node) {
if (tsutils.isPrefixUnaryExpression(node)) {
return tsutils.isNumericLiteral(node.operand) && node.operator === ts.SyntaxKind.MinusToken;
}
return tsutils.isNumericLiteral(node);
}
function isNecessaryDynamicAccess(argumentExpression) {
function complainOnNode(node) {
var newOperatorText = node.operator === ts.SyntaxKind.PlusPlusToken ? "+= 1" : "-= 1";
var replacement;
if (tsutils.isPrefixUnaryExpression(node) ||
node.parent.kind === ts.SyntaxKind.ExpressionStatement) {
replacement = createReplacement(node, newOperatorText);
}
var failure = Rule.FAILURE_STRING_FACTORY(newOperatorText);
context.addFailureAtNode(node, failure, replacement);
}
function checkPostfixUnaryExpression(node) {