Socket
Socket
Sign inDemoInstall

eslint-plugin-ts-immutable

Package Overview
Dependencies
162
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

5

CHANGELOG.md

@@ -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 @@

52

lib/index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc