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.11.0-dev.20180604 to 0.11.0-dev.20180607

2

package.json
{
"name": "@fimbul/mimir",
"version": "0.11.0-dev.20180604",
"version": "0.11.0-dev.20180607",
"description": "Core rules of the Fimbullinter project",

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

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

type = this.checker.getApparentType(type);
if (type.flags & ts.TypeFlags.Any)
if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))
return true;

@@ -48,3 +48,3 @@ for (const t of tsutils_1.unionTypeParts(type))

const type = this.checker.getApparentType(this.checker.getTypeAtLocation(node));
if (type.flags & ts.TypeFlags.Any)
if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))
return true;

@@ -51,0 +51,0 @@ for (const t of tsutils_1.unionTypeParts(type))

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

const result = {
known: (type.flags & ts.TypeFlags.Any) !== 0 ||
known: (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0 ||
type.getStringIndexType() === undefined && type.getNumberIndexType() === undefined,

@@ -83,0 +83,0 @@ names: [],

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

return;
for (let i = 0; i < typeArguments.length; ++i) {
for (let i = 0, len = Math.min(typeParameters.length, typeArguments.length); i < len; ++i) {
const typeArgument = typeArguments[i];

@@ -72,0 +72,0 @@ if (tsutils_1.isTypeLiteralNode(typeArgument) && typeArgument.members.length === 0)

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

checkTypeAssertion(node) {
let targetType = this.checker.getTypeAtLocation(node);
let targetType = this.checker.getTypeFromTypeNode(node.type);
if (targetType.flags & ts.TypeFlags.Literal ||

@@ -121,3 +121,3 @@ tsutils_1.isObjectType(targetType) && (targetType.objectFlags & ts.ObjectFlags.Tuple || couldBeTupleType(targetType)))

flags |= t.flags;
return ((receiver && flags & ts.TypeFlags.Any) ? -1 : flags) & (ts.TypeFlags.Null | ts.TypeFlags.Undefined);
return ((receiver && flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) ? -1 : flags) & (ts.TypeFlags.Null | ts.TypeFlags.Undefined);
}

@@ -124,0 +124,0 @@ function formatNullableFlags(flags) {

@@ -67,4 +67,3 @@ "use strict";

const checker = this.program.getTypeChecker();
const type = checker.getTypeAtLocation(node);
const apparentType = checker.getApparentType(type);
const type = checker.getApparentType(checker.getTypeAtLocation(node));
for (let i = 0; i < node.elements.length; ++i) {

@@ -77,6 +76,6 @@ const element = node.elements[i];

continue;
const symbol = apparentType.getProperty(name);
const symbol = type.getProperty(name);
if (symbol === undefined || symbolMaybeUndefined(checker, symbol, node))
continue;
const fix = checker.getTypeAtLocation(element.name).flags & (ts.TypeFlags.Union | ts.TypeFlags.Any)
const fix = checker.getTypeAtLocation(element.name).flags & (ts.TypeFlags.Union | ts.TypeFlags.Any | ts.TypeFlags.Unknown)
? undefined

@@ -139,3 +138,3 @@ : ymir_1.Replacement.delete(tsutils_1.getChildOfKind(element, ts.SyntaxKind.EqualsToken, this.sourceFile).pos, element.end);

return tsutils_1.unionTypeParts(checker.getTypeOfSymbolAtLocation(symbol, node))
.some((t) => (t.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Any)) !== 0);
.some((t) => (t.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0);
}

@@ -142,0 +141,0 @@ function isUndefined(node) {

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

}
if (t.flags & (ts.TypeFlags.Any | ts.TypeFlags.Never))
if (t.flags & (ts.TypeFlags.Any | ts.TypeFlags.Never | ts.TypeFlags.Unknown))
return;

@@ -202,0 +202,0 @@ switch (predicate(t)) {

@@ -37,4 +37,2 @@ "use strict";

isIterationPossible(type) {
if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Never))
return false;
type = this.checker.getBaseConstraintOfType(type) || type;

@@ -41,0 +39,0 @@ return tsutils_1.unionTypeParts(type).every(this.isIterationProtocolAvailable() ? isIterable : this.isArray, this);

import { TypedRule } from '@fimbul/ymir';
export declare class Rule extends TypedRule {
apply(): void;
private isNumberLikeType;
private isCorrectArgumentType;
}

@@ -17,16 +17,9 @@ "use strict";

if (tsutils_1.isCallExpression(parent) && parent.expression === node && parent.arguments.length === 1 &&
this.isNumberLikeType(this.checker.getTypeAtLocation(parent.arguments[0])))
this.isCorrectArgumentType(parent.arguments[0]))
this.addFailure(match.index, re.lastIndex, "Prefer 'Number.isNaN' over 'isNaN'.", ymir_1.Replacement.append(match.index, 'Number.'));
}
}
isNumberLikeType(type) {
if (tsutils_1.isTypeVariable(type)) {
const base = this.checker.getBaseConstraintOfType(type);
if (base === undefined)
return false;
type = base;
}
if (type.flags & ts.TypeFlags.NumberLike)
return true;
return tsutils_1.isUnionType(type) && type.types.every(this.isNumberLikeType, this);
isCorrectArgumentType(arg) {
const type = this.checker.getTypeAtLocation(arg);
return tsutils_1.unionTypeParts(this.checker.getBaseConstraintOfType(type) || type).every((t) => (t.flags & ts.TypeFlags.NumberLike) !== 0);
}

@@ -33,0 +26,0 @@ };

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

const type = this.checker.getTypeAtLocation(node);
if (type.flags & ts.TypeFlags.Any)
if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))
return true;

@@ -44,0 +44,0 @@ let seenObject = false;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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