@fimbul/mimir
Advanced tools
Comparing version 0.10.0-dev.20180510 to 0.10.0-dev.20180512
{ | ||
"name": "@fimbul/mimir", | ||
"version": "0.10.0-dev.20180510", | ||
"version": "0.10.0-dev.20180512", | ||
"description": "Core rules of the Fimbullinter project", | ||
@@ -32,3 +32,3 @@ "main": "recommended.yaml", | ||
"tslib": "^1.8.1", | ||
"tsutils": "^2.24.0" | ||
"tsutils": "^2.27.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "peerDependencies": { |
@@ -41,8 +41,8 @@ # Mímir | ||
[`no-unsafe-finally`](docs/no-unsafe-finally.md) | Disallows control flow statements `return`, `throw`, `break` and `continue` inside the `finally` block of a try statement. | Performance! | ||
`no-unstable-api-use` | Finds uses of deprecated and experimental variables, classes, properties, functions, signatures, ... *requires type information* | This rule checks element accesses (`foo[bar]`), JSX elements, chained function calls (`getFn()()`) in addition to what TSLint's `deprecation` rule does and has more useful error reporting. | ||
`no-unused-expression` | Warns about side-effect free expressions whose value is not used | This one is a bit stricter than TSLint's `no-unused-expression` and checks `for` loops in addition. | ||
`no-unused-label` | Warns about labels that are never used or at the wrong position. | TSLint only has `label-position` which doesn't check for unused labels. | ||
`no-useless-assertion` | Detects type assertions that don't change the type or are not necessary in the first place. *requires type information* | TSLint's `no-unnecessary-type-assertion` does not detect assertions needed to silence the compiler warning `Variable ... is used before being assigned.` The Wotan builtin rule also checks whether the assertion is necessary at all or the receiver accepts the original type. | ||
`no-useless-declare` | Disallows the `declare` keyword on statements without runtime value, e.g. `declare type T = any;`. | TSLint has no such rule. | ||
`no-useless-initializer` | Detects unnecessary initialization with `undefined` and destructuring defaults (*requires type information*). | TSLint's rule `no-unnecessary-initializer` doesn't fix all parameter initializers and gives false positives for destructuring. | ||
[`no-unstable-api-use`](docs/no-unstable-api-use.md) | :mag: Disallows uses of deprecated or experimental APIs. | This rule checks element accesses (`foo[bar]`), JSX elements, chained function calls (`getFn()()`) in addition to what TSLint's `deprecation` rule does and has more useful error reporting. | ||
[`no-unused-expression`](docs/no-unused-expression.md) | :nut_and_bolt: Disallows side-effect free expressions whose value is not used. | This one is a bit stricter than TSLint's `no-unused-expression` and checks `for` loops in addition. | ||
[`no-unused-label`](docs/no-unused-label.md) | :wrench: Disallows labels that are never used. | TSLint only has `label-position` which doesn't check for unused labels. | ||
[`no-useless-assertion`](docs/no-useless-assertion.md) | :mag: :wrench: Disallows type assertions that don't change the type or are not necessary in the first place. | TSLint's `no-unnecessary-type-assertion` does not detect assertions needed to silence the compiler warning `Variable ... is used before being assigned.` The Wotan builtin rule also checks whether the assertion is necessary at all or the receiver accepts the original type. | ||
[`no-useless-declare`](docs/no-useless-declare.md) | :wrench: Disallows the `declare` keyword on statements without runtime value, e.g. `declare type T = any;`. | TSLint has no such rule. | ||
[`no-useless-initializer`](docs/no-useless-initializer.md) | :mag_right: :wrench: Disallows unnecessary initialization with `undefined` and useless destructuring defaults. | TSLint's rule `no-unnecessary-initializer` doesn't fix all parameter initializers and gives false positives for destructuring. | ||
`no-useless-jump-label` | Detects `continue label;` and `break label;` where the label is not necessary. | There's no similar TSLint rule. | ||
@@ -49,0 +49,0 @@ `no-useless-predicate` | Detects redundant conditions that are either always true or always false. *requires type information* | Combination of TSLint's `strict-type-predicates`, `typeof-compare` and parts of `strict-boolean-expressions`. |
@@ -18,3 +18,3 @@ "use strict"; | ||
tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword, ts.SyntaxKind.DeclareKeyword) || | ||
isAmbientModuleBlock(node.parent)) | ||
tsutils_1.isAmbientModuleBlock(node.parent)) | ||
continue; | ||
@@ -38,13 +38,2 @@ for (const declaration of node.declarationList.declarations) | ||
exports.Rule = Rule; | ||
function isAmbientModuleBlock(node) { | ||
while (node.kind === ts.SyntaxKind.ModuleBlock) { | ||
do | ||
node = node.parent; | ||
while (node.flags & ts.NodeFlags.NestedNamespace); | ||
if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) | ||
return true; | ||
node = node.parent; | ||
} | ||
return false; | ||
} | ||
//# sourceMappingURL=no-unassigned-variable.js.map |
@@ -143,3 +143,3 @@ "use strict"; | ||
let useFunctionScope = findupFunction(node.parent.parent); | ||
while (useFunctionScope !== declaringFunctionScope && isIife(useFunctionScope)) | ||
while (useFunctionScope !== declaringFunctionScope && isInlinedIife(useFunctionScope)) | ||
useFunctionScope = findupFunction(useFunctionScope.parent.parent); | ||
@@ -153,13 +153,7 @@ return useFunctionScope === declaringFunctionScope; | ||
} | ||
function isIife(node) { | ||
if (!tsutils_1.isFunctionExpression(node) && !tsutils_1.isArrowFunction(node) || | ||
node.asteriskToken !== undefined || | ||
tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)) | ||
return false; | ||
let prev; | ||
do { | ||
prev = node; | ||
node = node.parent; | ||
} while (node.kind === ts.SyntaxKind.ParenthesizedExpression); | ||
return tsutils_1.isCallExpression(node) && node.expression === prev; | ||
function isInlinedIife(node) { | ||
return (tsutils_1.isFunctionExpression(node) || tsutils_1.isArrowFunction(node)) && | ||
node.asteriskToken === undefined && | ||
!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) && | ||
tsutils_1.getIIFE(node) !== undefined; | ||
} | ||
@@ -166,0 +160,0 @@ function couldBeTupleType(type) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
328898
156
3488
Updatedtsutils@^2.27.0