Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fimbul/mimir

Package Overview
Dependencies
Maintainers
2
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fimbul/mimir - npm Package Compare versions

Comparing version 0.19.0-dev.20190119 to 0.19.0-dev.20190120

2

package.json
{
"name": "@fimbul/mimir",
"version": "0.19.0-dev.20190119",
"version": "0.19.0-dev.20190120",
"description": "Core rules of the Fimbullinter project",

@@ -5,0 +5,0 @@ "main": "recommended.yaml",

@@ -16,2 +16,3 @@ import { TypedRule } from '@fimbul/ymir';

private getTypeOfExpression;
private isPropertyPresent;
}

@@ -86,3 +86,3 @@ "use strict";

}
else if (isEqualityOperator(node.operatorToken.kind)) {
else if (isEqualityOrInOperator(node.operatorToken.kind)) {
this.checkNode(node);

@@ -93,3 +93,3 @@ }

if (node.operator === ts.SyntaxKind.ExclamationToken)
this.checkNode(node.operand);
this.checkCondition(node.operand);
}

@@ -106,10 +106,6 @@ }

checkCondition(node) {
node = utils_1.unwrapParens(node);
if (tsutils_1.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken ||
tsutils_1.isBinaryExpression(node) && isEqualityOperator(node.operatorToken.kind))
return;
return this.checkNode(node);
return this.maybeFail(node, this.isTruthyFalsy(node, true));
}
checkNode(node) {
return this.maybeFail(node, this.isTruthyFalsy(node));
return this.maybeFail(node, this.isTruthyFalsy(node, false));
}

@@ -120,21 +116,16 @@ maybeFail(node, result) {

}
isTruthyFalsy(node) {
isTruthyFalsy(node, nested) {
if (tsutils_1.isBinaryExpression(node)) {
if (isEqualityOperator(node.operatorToken.kind))
return this.isConstantComparison(node.left, node.right, node.operatorToken.kind);
return nested ? undefined : this.isConstantComparison(node.left, node.right, node.operatorToken.kind);
if (node.operatorToken.kind === ts.SyntaxKind.InKeyword)
return nested ? undefined : this.isPropertyPresent(node.right, node.left);
}
else if (tsutils_1.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) {
switch (this.isTruthyFalsy(node.operand)) {
case true:
return false;
case false:
return true;
default:
return;
}
return;
}
else if (tsutils_1.isParenthesizedExpression(node)) {
return this.isTruthyFalsy(node.expression);
return this.isTruthyFalsy(node.expression, true);
}
return this.executePredicate(this.getTypeOfExpression(node), truthyFalsy);
return this.executePredicate(this.getTypeOfExpression(node), this.strictNullChecks ? truthyFalsy : falsy);
}

@@ -265,2 +256,18 @@ isConstantComparison(left, right, operator) {

}
isPropertyPresent(node, name) {
if (!this.strictNullChecks)
return;
const names = utils_1.lateBoundPropertyNames(name, this.checker);
if (!names.known)
return;
const types = tsutils_1.unionTypeParts(this.checker.getApparentType(this.getTypeOfExpression(utils_1.unwrapParens(node))));
for (const { symbolName } of names.properties) {
for (const type of types) {
const symbol = utils_1.getPropertyOfType(type, symbolName);
if (symbol === undefined || symbol.flags & ts.SymbolFlags.Optional)
return;
}
}
return true;
}
};

@@ -274,2 +281,5 @@ Rule = tslib_1.__decorate([

}
function falsy(type) {
return tsutils_1.isFalsyType(type) ? false : undefined;
}
function truthyFalsy(type) {

@@ -286,2 +296,5 @@ if (type.flags & ts.TypeFlags.PossiblyFalsy) {

}
function isEqualityOrInOperator(kind) {
return isEqualityOperator(kind) || kind === ts.SyntaxKind.InKeyword;
}
function isEqualityOperator(kind) {

@@ -288,0 +301,0 @@ switch (kind) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc