New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.12.0 to 0.13.0-dev.20180718

docs/no-useless-strict.md

6

package.json
{
"name": "@fimbul/mimir",
"version": "0.12.0",
"version": "0.13.0-dev.20180718",
"description": "Core rules of the Fimbullinter project",

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

"dependencies": {
"@fimbul/ymir": "^0.11.0",
"@fimbul/ymir": "0.13.0-dev.20180718",
"chalk": "^2.3.2",
"debug": "^3.1.0",
"tslib": "^1.8.1",
"tsutils": "^2.27.2"
"tsutils": "^2.28.0"
},

@@ -35,0 +35,0 @@ "peerDependencies": {

@@ -58,2 +58,3 @@ # Mímir

[`no-useless-spread`](docs/no-useless-spread.md) | :wrench: Disallows redundant array and object spread. | There's no similar TSLint rule.
[`no-useless-strict`](docs/no-useless-strict.md) | :mag_right: :wrench: Disallows redundant `'use strict';` directives. | TSLint had a rule to enforce `'use strict'` everywhere.
[`parameter-properties`](docs/parameter-properties.md) | :wrench: :nut_and_bolt: :x: Enforces or disallows the use of parameter properties. | TSlint only has `no-parameter-properties` to disallow all parameter properties and has no autofixer.

@@ -60,0 +61,0 @@ [`prefer-const`](docs/prefer-const.md) | :wrench: :nut_and_bolt: Enforces the use of `const` for variables that are never reassigned. | TSLint's `prefer-const` rule gives some false positives for merged declarations and variables used before being declared which results in a compiler or runtime error after fixing.

@@ -7,2 +7,3 @@ "use strict";

const tsutils_1 = require("tsutils");
const utils_1 = require("../utils");
const FAIL_MESSAGE = 'This expression is unused. Did you mean to assign a value or call a function?';

@@ -91,3 +92,3 @@ let Rule = class Rule extends ymir_1.ConfigurableRule {

const parent = statement.parent;
if (!canContainDirective(parent))
if (!utils_1.hasDirectivePrologue(parent))
return false;

@@ -100,24 +101,2 @@ for (let i = parent.statements.indexOf(statement) - 1; i >= 0; --i)

}
function canContainDirective(node) {
switch (node.kind) {
case ts.SyntaxKind.SourceFile:
case ts.SyntaxKind.ModuleBlock:
return true;
case ts.SyntaxKind.Block:
switch (node.parent.kind) {
case ts.SyntaxKind.ArrowFunction:
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.FunctionDeclaration:
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.Constructor:
case ts.SyntaxKind.GetAccessor:
case ts.SyntaxKind.SetAccessor:
return true;
default:
return false;
}
default:
return false;
}
}
function isAllowedVoidExpression(expr) {

@@ -124,0 +103,0 @@ if (expr.kind === ts.SyntaxKind.ParenthesizedExpression)

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

super(...arguments);
this.strictNullChecks = utils_1.isStrictNullChecksEnabled(this.program.getCompilerOptions());
this.strictNullChecks = tsutils_1.isStrictCompilerOptionEnabled(this.program.getCompilerOptions(), 'strictNullChecks');
}

@@ -38,3 +38,3 @@ apply() {

if (node.exclamationToken !== undefined &&
node.initializer === undefined && (!utils_1.isStrictNullChecksEnabled(this.program.getCompilerOptions()) ||
node.initializer === undefined && (!tsutils_1.isStrictCompilerOptionEnabled(this.program.getCompilerOptions(), 'strictNullChecks') ||
getNullableFlags(this.checker.getTypeAtLocation(node.name), true) & ts.TypeFlags.Undefined))

@@ -47,3 +47,3 @@ this.addFailure(node.exclamationToken.end - 1, node.exclamationToken.end, FAIL_DEFINITE_ASSIGNMENT, ymir_1.Replacement.delete(node.exclamationToken.pos, node.exclamationToken.end));

!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AbstractKeyword) && (node.name.kind !== ts.SyntaxKind.Identifier ||
!utils_1.isStrictPropertyInitializationEnabled(this.program.getCompilerOptions()) ||
!tsutils_1.isStrictCompilerOptionEnabled(this.program.getCompilerOptions(), 'strictPropertyInitialization') ||
getNullableFlags(this.checker.getTypeAtLocation(node), true) & ts.TypeFlags.Undefined))

@@ -50,0 +50,0 @@ this.addFailure(node.exclamationToken.end - 1, node.exclamationToken.end, FAIL_DEFINITE_ASSIGNMENT, ymir_1.Replacement.delete(node.exclamationToken.pos, node.exclamationToken.end));

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

checkObjectDestructuring(node) {
if (this.program === undefined || !utils_1.isStrictNullChecksEnabled(this.program.getCompilerOptions()))
if (this.program === undefined || !tsutils_1.isStrictCompilerOptionEnabled(this.program.getCompilerOptions(), 'strictNullChecks'))
return;

@@ -65,3 +65,3 @@ const checker = this.program.getTypeChecker();

checkBindingPattern(node, propNames) {
if (this.program === undefined || !utils_1.isStrictNullChecksEnabled(this.program.getCompilerOptions()))
if (this.program === undefined || !tsutils_1.isStrictCompilerOptionEnabled(this.program.getCompilerOptions(), 'strictNullChecks'))
return;

@@ -68,0 +68,0 @@ const checker = this.program.getTypeChecker();

@@ -7,3 +7,2 @@ "use strict";

const tsutils_1 = require("tsutils");
const utils_1 = require("../utils");
const primitiveFlags = ts.TypeFlags.BooleanLike | ts.TypeFlags.NumberLike | ts.TypeFlags.StringLike | ts.TypeFlags.ESSymbolLike |

@@ -54,3 +53,3 @@ ts.TypeFlags.Undefined | ts.TypeFlags.Void;

super(...arguments);
this.strictNullChecks = utils_1.isStrictNullChecksEnabled(this.program.getCompilerOptions());
this.strictNullChecks = tsutils_1.isStrictCompilerOptionEnabled(this.program.getCompilerOptions(), 'strictNullChecks');
}

@@ -57,0 +56,0 @@ apply() {

import * as ts from 'typescript';
import { VariableUse } from 'tsutils';
import { RuleContext } from '@fimbul/ymir';
export declare function isStrictNullChecksEnabled(options: ts.CompilerOptions): boolean;
export declare function isStrictPropertyInitializationEnabled(options: ts.CompilerOptions): boolean;
export declare function switchStatements(context: RuleContext): IterableIterator<ts.SwitchStatement>;

@@ -34,1 +32,2 @@ export declare function isAsyncFunction(node: ts.Node): node is ts.FunctionLikeDeclaration & {

export declare function escapeIdentifier(name: string): ts.__String;
export declare function hasDirectivePrologue(node: ts.Node): node is ts.BlockLike;

@@ -5,12 +5,2 @@ "use strict";

const tsutils_1 = require("tsutils");
function isStrictNullChecksEnabled(options) {
return options.strict ? options.strictNullChecks !== false : options.strictNullChecks === true;
}
exports.isStrictNullChecksEnabled = isStrictNullChecksEnabled;
function isStrictPropertyInitializationEnabled(options) {
return options.strict
? options.strictPropertyInitialization !== false && options.strictNullChecks !== false
: options.strictPropertyInitialization === true && options.strictNullChecks === true;
}
exports.isStrictPropertyInitializationEnabled = isStrictPropertyInitializationEnabled;
function* switchStatements(context) {

@@ -196,2 +186,25 @@ const { text } = context.sourceFile;

exports.escapeIdentifier = escapeIdentifier;
function hasDirectivePrologue(node) {
switch (node.kind) {
case ts.SyntaxKind.SourceFile:
case ts.SyntaxKind.ModuleBlock:
return true;
case ts.SyntaxKind.Block:
switch (node.parent.kind) {
case ts.SyntaxKind.ArrowFunction:
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.FunctionDeclaration:
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.Constructor:
case ts.SyntaxKind.GetAccessor:
case ts.SyntaxKind.SetAccessor:
return true;
default:
return false;
}
default:
return false;
}
}
exports.hasDirectivePrologue = hasDirectivePrologue;
//# sourceMappingURL=utils.js.map

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