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.6.0 to 0.7.0-dev.20180325

4

package.json
{
"name": "@fimbul/mimir",
"version": "0.6.0",
"version": "0.7.0-dev.20180325",
"description": "Core rules of the Fimbullinter project",

@@ -28,3 +28,3 @@ "main": "recommended.yaml",

"dependencies": {
"@fimbul/ymir": "^0.6.0",
"@fimbul/ymir": "0.6.0",
"chalk": "^2.3.2",

@@ -31,0 +31,0 @@ "debug": "^3.1.0",

@@ -58,5 +58,4 @@ "use strict";

const originalType = this.checker.getTypeAtLocation(node.expression);
const flags = getNullableFlags(!typescriptPre270 || originalType.flags & ts.TypeFlags.IndexedAccess
? this.checker.getApparentType(originalType)
: originalType);
const flags = getNullableFlags((!typescriptPre270 || originalType.flags & ts.TypeFlags.IndexedAccess) &&
this.checker.getBaseConstraintOfType(originalType) || originalType);
if (flags !== 0) {

@@ -81,5 +80,5 @@ const contextualType = this.getSafeContextualType(node);

let sourceType = this.checker.getTypeAtLocation(node.expression);
if ((targetType.flags & ts.TypeFlags.TypeParameter) === 0 && (sourceType.flags & ts.TypeFlags.Literal) === 0) {
targetType = this.checker.getApparentType(targetType);
sourceType = this.checker.getApparentType(sourceType);
if ((targetType.flags & (ts.TypeFlags.TypeVariable | ts.TypeFlags.Instantiable)) === 0) {
targetType = this.checker.getBaseConstraintOfType(targetType) || targetType;
sourceType = this.checker.getBaseConstraintOfType(sourceType) || sourceType;
}

@@ -86,0 +85,0 @@ let message = FAIL_MESSAGE;

@@ -144,25 +144,28 @@ "use strict";

if (tsutils_1.isTypeOfExpression(left)) {
left = unwrapParens(left.expression);
if (right.kind === ts.SyntaxKind.NullKeyword || isUndefined(right))
return equals.negated;
let literal;
if (tsutils_1.isTextualLiteral(right)) {
switch (right.text) {
case 'number':
case 'string':
case 'boolean':
case 'symbol':
case 'object':
case 'function':
case 'undefined':
left = unwrapParens(left.expression);
predicate = predicates[right.text];
break;
default:
return equals.negated;
}
literal = right.text;
}
else if (right.kind === ts.SyntaxKind.NullKeyword ||
tsutils_1.isIdentifier(right) && right.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) {
return equals.negated;
}
else {
return;
let type = this.checker.getTypeAtLocation(right);
type = this.checker.getBaseConstraintOfType(type) || type;
if ((type.flags & ts.TypeFlags.StringLiteral) === 0)
return;
literal = type.value;
}
switch (literal) {
default:
return equals.negated;
case 'number':
case 'string':
case 'boolean':
case 'symbol':
case 'object':
case 'function':
case 'undefined':
predicate = predicates[literal];
}
}

@@ -172,3 +175,3 @@ else if (right.kind === ts.SyntaxKind.NullKeyword) {

}
else if (tsutils_1.isIdentifier(right) && right.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) {
else if (isUndefined(right)) {
predicate = equals.strict ? predicates.undefined : predicates.nullOrUndefined;

@@ -222,2 +225,5 @@ }

exports.Rule = Rule;
function isUndefined(node) {
return tsutils_1.isIdentifier(node) && node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword;
}
function truthyFalsy(type) {

@@ -224,0 +230,0 @@ if (type.flags & ts.TypeFlags.PossiblyFalsy) {

Sorry, the diff of this file is not supported yet

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