Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tslint-immutable

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tslint-immutable - npm Package Compare versions

Comparing version 4.5.2 to 4.5.3

.nyc_output/82ae813dc6ca878ff9f67d0b1062a568.json

9

CHANGELOG.md

@@ -10,2 +10,8 @@ # Change Log

## [v4.5.3] - 2018-03-31
### Fixed
* `readonly-array` fixer does not work for arrays with nested template type. See [#24](https://github.com/jonaskello/tslint-immutable/issues/24). Thanks to [@geon](https://github.com/geon) for fixing this longstanding bug! (See PR [#78](https://github.com/jonaskello/tslint-immutable/pull/78))
## [v4.5.2] - 2018-02-27

@@ -244,3 +250,4 @@

[unreleased]: https://github.com/jonaskello/tslint-immutable/compare/v4.5.2...master
[unreleased]: https://github.com/jonaskello/tslint-immutable/compare/v4.5.3...master
[v4.5.3]: https://github.com/jonaskello/tslint-immutable/compare/v4.5.2...v4.5.3
[v4.5.2]: https://github.com/jonaskello/tslint-immutable/compare/v4.5.1...v4.5.2

@@ -247,0 +254,0 @@ [v4.5.1]: https://github.com/jonaskello/tslint-immutable/compare/v4.5.0...v4.5.1

2

package.json
{
"name": "tslint-immutable",
"version": "4.5.2",
"version": "4.5.3",
"description": "TSLint rules to disable mutation in TypeScript.",

@@ -5,0 +5,0 @@ "main": "tslint-immutable.json",

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

node.kind === ts.SyntaxKind.ClassDeclaration)
? { invalidNodes: [check_node_1.createInvalidNode(node)] }
? { invalidNodes: [check_node_1.createInvalidNode(node, [])] }
: {

@@ -14,0 +14,0 @@ invalidNodes: []

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

return node && node.kind === ts.SyntaxKind.DeleteExpression
? { invalidNodes: [check_node_1.createInvalidNode(node)] }
? { invalidNodes: [check_node_1.createInvalidNode(node, [])] }
: {

@@ -12,0 +12,0 @@ invalidNodes: []

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

if (!isYield && !isIgnored2) {
return { invalidNodes: [check_node_1.createInvalidNode(esNode)] };
return { invalidNodes: [check_node_1.createInvalidNode(esNode, [])] };
}

@@ -23,0 +23,0 @@ }

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

return node && node.kind === ts.SyntaxKind.IfStatement
? { invalidNodes: [check_node_1.createInvalidNode(node)] }
? { invalidNodes: [check_node_1.createInvalidNode(node, [])] }
: {

@@ -12,0 +12,0 @@ invalidNodes: []

@@ -53,4 +53,6 @@ "use strict";

invalidVariableDeclarationNodes.push(check_node_1.createInvalidNode(variableDeclarationNode, addFix
? new Lint.Replacement(declarationList.getStart(ctx.sourceFile), "let".length, "const")
: undefined));
? [
new Lint.Replacement(declarationList.getStart(ctx.sourceFile), "let".length, "const")
]
: []));
addFix = false;

@@ -57,0 +59,0 @@ }

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

node.kind === ts.SyntaxKind.DoStatement)
? { invalidNodes: [check_node_1.createInvalidNode(node)] }
? { invalidNodes: [check_node_1.createInvalidNode(node, [])] }
: {

@@ -17,0 +17,0 @@ invalidNodes: []

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

return node && node.kind === ts.SyntaxKind.MethodSignature
? { invalidNodes: [check_node_1.createInvalidNode(node)] }
? { invalidNodes: [check_node_1.createInvalidNode(node, [])] }
: {

@@ -12,0 +12,0 @@ invalidNodes: []

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

(prevMemberKind !== memberKind || prevMemberType !== memberType)) {
invalidNodes.push(check_node_1.createInvalidNode(member));
invalidNodes.push(check_node_1.createInvalidNode(member, []));
}

@@ -32,0 +32,0 @@ prevMemberKind = memberKind;

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

!Ignore.isIgnoredPrefix(binExp_1.getText(node.getSourceFile()), ctx.options.ignorePrefix)) {
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node)]);
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node, [])]);
}

@@ -48,3 +48,3 @@ }

!Ignore.isIgnoredPrefix(delExp_1.expression.getText(node.getSourceFile()), ctx.options.ignorePrefix)) {
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node)]);
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node, [])]);
}

@@ -58,3 +58,3 @@ }

!Ignore.isIgnoredPrefix(preExp_1.operand.getText(node.getSourceFile()), ctx.options.ignorePrefix)) {
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node)]);
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node, [])]);
}

@@ -68,3 +68,3 @@ }

!Ignore.isIgnoredPrefix(postExp_1.getText(node.getSourceFile()), ctx.options.ignorePrefix)) {
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node)]);
invalidNodes = invalidNodes.concat([check_node_1.createInvalidNode(node, [])]);
}

@@ -71,0 +71,0 @@ }

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

return node && node.kind === ts.SyntaxKind.ThisKeyword
? { invalidNodes: [check_node_1.createInvalidNode(node)] }
? { invalidNodes: [check_node_1.createInvalidNode(node, [])] }
: {

@@ -12,0 +12,0 @@ invalidNodes: []

@@ -10,12 +10,9 @@ "use strict";

function checkNode(node, ctx) {
var explicitTypeFailures = checkArrayTypeOrReference(node, ctx);
var implicitTypeFailures = checkVariableOrParameterImplicitType(node, ctx);
return { invalidNodes: explicitTypeFailures.concat(implicitTypeFailures) };
return {
invalidNodes: checkArrayType(node, ctx).concat(checkTypeReference(node, ctx), checkVariableOrParameterImplicitType(node, ctx))
};
}
function checkArrayTypeOrReference(node, ctx) {
// We need to check both shorthand syntax "number[]" and type reference "Array<number>"
if (node.kind === ts.SyntaxKind.ArrayType ||
(node.kind === ts.SyntaxKind.TypeReference &&
node.typeName.getText(ctx.sourceFile) ===
"Array")) {
function checkArrayType(node, ctx) {
// We need to check both shorthand syntax "number[]"...
if (node.kind === ts.SyntaxKind.ArrayType) {
if (node.parent &&

@@ -25,18 +22,23 @@ Ignore.shouldIgnorePrefix(node.parent, ctx.options, ctx.sourceFile)) {

}
var typeArgument = "T";
if (node.kind === ts.SyntaxKind.ArrayType) {
var typeNode = node;
typeArgument = typeNode.elementType.getFullText(ctx.sourceFile).trim();
return [
check_node_1.createInvalidNode(node, [
new Lint.Replacement(node.getStart(ctx.sourceFile), 0, "ReadonlyArray<"),
new Lint.Replacement(node.end - 2, 2, ">")
])
];
}
return [];
}
function checkTypeReference(node, ctx) {
// ...and type reference "Array<number>"
if (node.kind === ts.SyntaxKind.TypeReference &&
node.typeName.getText(ctx.sourceFile) === "Array") {
if (node.parent &&
Ignore.shouldIgnorePrefix(node.parent, ctx.options, ctx.sourceFile)) {
return [];
}
else if (node.kind === ts.SyntaxKind.TypeReference) {
var typeNode = node;
if (typeNode.typeArguments) {
typeArgument = typeNode.typeArguments[0]
.getFullText(ctx.sourceFile)
.trim();
}
}
var length_1 = node.getWidth(ctx.sourceFile);
return [
check_node_1.createInvalidNode(node, new Lint.Replacement(node.end - length_1, length_1, "ReadonlyArray<" + typeArgument + ">"))
check_node_1.createInvalidNode(node, [
new Lint.Replacement(node.getStart(ctx.sourceFile), 0, "Readonly")
])
];

@@ -58,3 +60,3 @@ }

varOrParamNode.initializer.kind === ts.SyntaxKind.ArrayLiteralExpression) {
var length_2 = varOrParamNode.name.getWidth(ctx.sourceFile);
var length_1 = varOrParamNode.name.getWidth(ctx.sourceFile);
var nameText = varOrParamNode.name.getText(ctx.sourceFile);

@@ -75,3 +77,5 @@ var typeArgument = "any";

return [
check_node_1.createInvalidNode(varOrParamNode.name, new Lint.Replacement(varOrParamNode.name.end - length_2, length_2, nameText + ": ReadonlyArray<" + typeArgument + ">"))
check_node_1.createInvalidNode(varOrParamNode.name, [
new Lint.Replacement(varOrParamNode.name.end - length_1, length_1, nameText + ": ReadonlyArray<" + typeArgument + ">")
])
];

@@ -78,0 +82,0 @@ }

@@ -28,3 +28,5 @@ "use strict";

return [
check_node_1.createInvalidNode(node, new Lint.Replacement(node.getStart(ctx.sourceFile), 0, "readonly "))
check_node_1.createInvalidNode(node, [
new Lint.Replacement(node.getStart(ctx.sourceFile), 0, "readonly ")
])
];

@@ -31,0 +33,0 @@ }

@@ -22,4 +22,4 @@ /**

var options_1 = require("./options");
function createInvalidNode(node, replacement) {
return { node: node, replacement: replacement };
function createInvalidNode(node, replacements) {
return { node: node, replacements: replacements };
}

@@ -64,5 +64,5 @@ exports.createInvalidNode = createInvalidNode;

invalidNodes.forEach(function (invalidNode) {
return ctx.addFailureAtNode(invalidNode.node, failureString, invalidNode.replacement);
return ctx.addFailureAtNode(invalidNode.node, failureString, invalidNode.replacements);
});
}
//# sourceMappingURL=check-node.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

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

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

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