eslint-plugin-ts-immutable
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -10,2 +10,7 @@ # Change Log | ||
## [v0.2.1] - 2019-07-12 | ||
Remove fixer for `no-let`. | ||
TypeScript is no longer imported unless it is available. | ||
## [v0.2.0] - 2019-07-12 | ||
@@ -12,0 +17,0 @@ |
@@ -8,3 +8,2 @@ 'use strict'; | ||
var escapeRegExp = _interopDefault(require('escape-string-regexp')); | ||
var ts = _interopDefault(require('typescript')); | ||
var experimentalUtils = require('@typescript-eslint/experimental-utils'); | ||
@@ -131,9 +130,2 @@ var astNodeTypes = require('@typescript-eslint/typescript-estree/dist/ts-estree/ast-node-types'); | ||
} | ||
function isForXInitialiser(node) { | ||
var forX = getForXStatement(node); | ||
return forX !== null && forX.left === node; | ||
} | ||
function isForXStatement(node) { | ||
return node.type === "ForInStatement" || node.type === "ForOfStatement"; | ||
} | ||
function isFunctionLike(node) { | ||
@@ -184,3 +176,12 @@ return (node.type === "FunctionDeclaration" || | ||
function isUnionType(type) { | ||
return type.flags === ts.TypeFlags.Union; | ||
// TODO: Find a nicer why to conditionally require typescript. | ||
/* eslint-disable-next-line ts-immutable/no-try */ | ||
try { | ||
// Cannot use top-level typescript import - that is for types only, not values. | ||
/* eslint-disable-next-line @typescript-eslint/no-require-imports */ | ||
return type.flags === require("typescript").TypeFlags.Union; | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
} | ||
@@ -228,8 +229,2 @@ function isArrayType(type) { | ||
/** | ||
* Test if the given node is in a ForX Statememt. | ||
*/ | ||
function getForXStatement(node) { | ||
return getParentOfType(isForXStatement, node); | ||
} | ||
/** | ||
* Is the given node in the return type. | ||
@@ -414,3 +409,3 @@ */ | ||
const version = "0.1.0"; | ||
const version = "0.2.0"; | ||
@@ -847,26 +842,3 @@ /** | ||
context: context, | ||
descriptors: node.kind === "let" | ||
? [ | ||
{ | ||
node: node, | ||
messageId: "generic", | ||
fix: | ||
/* | ||
* TODO: Remove this fix? | ||
* This fix doesn't actually fix the problem; it just turns the | ||
* let into a const and makes "cannot reassign to const" issues. | ||
* | ||
* Note: The rule "prefer-const"'s fix will fix lets only when | ||
* they aren't reassigned to. | ||
*/ | ||
// Can only fix if all declarations have an initial value (with the | ||
// exception of ForOf and ForIn Statement initialisers). | ||
node.declarations.every(function (declaration) { return declaration.init !== null; }) || isForXInitialiser(node) | ||
? function (fixer) { | ||
return fixer.replaceTextRange([node.range[0], node.range[0] + node.kind.length], "const"); | ||
} | ||
: undefined | ||
} | ||
] | ||
: [] | ||
descriptors: node.kind === "let" ? [{ node: node, messageId: "generic" }] : [] | ||
}; | ||
@@ -873,0 +845,0 @@ } |
{ | ||
"name": "eslint-plugin-ts-immutable", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "ESLint rules to disable mutation in TypeScript.", | ||
@@ -76,2 +76,5 @@ "main": "lib/index.js", | ||
}, | ||
"optionalDependencies": { | ||
"typescript": ">=3.4.1" | ||
}, | ||
"scripts": { | ||
@@ -78,0 +81,0 @@ "compile": "rollup -c", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
113706
7
2941