Socket
Socket
Sign inDemoInstall

eslint-plugin-functional

Package Overview
Dependencies
201
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.2 to 3.1.0

7

CHANGELOG.md

@@ -10,2 +10,9 @@ # Changelog

## [v3.1.0](https://github.com/jonaskello/eslint-plugin-functional/compare/v3.0.2...v3.1.0) - 2020-10-07
### Commits
- feat(prefer-readonly-type): add option ignoreCollections [`b6856fa`](https://github.com/jonaskello/eslint-plugin-functional/commit/b6856fa9d8a3182273c2f41dbcdd94bf88025b6a)
- docs(prefer-type-literal): remove mention of removed option allowLocalMutation from docs [`83da8bf`](https://github.com/jonaskello/eslint-plugin-functional/commit/83da8bf4fe5e368af65e18d6f29942d31a00f863)
## [v3.0.2](https://github.com/jonaskello/eslint-plugin-functional/compare/v3.0.1...v3.0.2) - 2020-08-23

@@ -12,0 +19,0 @@

95

lib/index.js

@@ -558,3 +558,3 @@ 'use strict';

const version = "3.0.1";
const version = "3.0.2";

@@ -1643,2 +1643,5 @@ // Polyfill.

},
ignoreCollections: {
type: "boolean",
},
},

@@ -1654,2 +1657,3 @@ additionalProperties: false,

ignoreInterface: false,
ignoreCollections: false,
allowLocalMutation: false,

@@ -1683,2 +1687,3 @@ allowMutableReturnType: false,

]);
const mutableTypeRegex = new RegExp(`^${Array.from(mutableToImmutableTypes.keys()).join("|")}$`);
/**

@@ -1688,22 +1693,30 @@ * Check if the given ArrayType or TupleType violates this rule.

function checkArrayOrTupleType(node, context, options) {
return {
context,
descriptors: (!node.parent ||
!isTSTypeOperator(node.parent) ||
node.parent.operator !== "readonly") &&
(!options.allowMutableReturnType || !isInReturnType(node))
? [
{
node,
messageId: isTSTupleType(node) ? "tuple" : "array",
fix: node.parent && isTSArrayType(node.parent)
? (fixer) => [
fixer.insertTextBefore(node, "(readonly "),
fixer.insertTextAfter(node, ")"),
]
: (fixer) => fixer.insertTextBefore(node, "readonly "),
},
]
: [],
};
if (options.ignoreCollections) {
return {
context,
descriptors: [],
};
}
else {
return {
context,
descriptors: (!node.parent ||
!isTSTypeOperator(node.parent) ||
node.parent.operator !== "readonly") &&
(!options.allowMutableReturnType || !isInReturnType(node))
? [
{
node,
messageId: isTSTupleType(node) ? "tuple" : "array",
fix: node.parent && isTSArrayType(node.parent)
? (fixer) => [
fixer.insertTextBefore(node, "(readonly "),
fixer.insertTextAfter(node, ")"),
]
: (fixer) => fixer.insertTextBefore(node, "readonly "),
},
]
: [],
};
}
}

@@ -1732,16 +1745,25 @@ /**

if (isIdentifier(node.typeName)) {
const immutableType = mutableToImmutableTypes.get(node.typeName.name);
return {
context,
descriptors: immutableType &&
(!options.allowMutableReturnType || !isInReturnType(node))
? [
{
node,
messageId: "type",
fix: (fixer) => fixer.replaceText(node.typeName, immutableType),
},
]
: [],
};
if (options.ignoreCollections &&
node.typeName.name.match(mutableTypeRegex)) {
return {
context,
descriptors: [],
};
}
else {
const immutableType = mutableToImmutableTypes.get(node.typeName.name);
return {
context,
descriptors: immutableType &&
(!options.allowMutableReturnType || !isInReturnType(node))
? [
{
node,
messageId: "type",
fix: (fixer) => fixer.replaceText(node.typeName, immutableType),
},
]
: [],
};
}
}

@@ -1801,3 +1823,4 @@ else {

declarator.init !== null &&
isArrayType(getTypeOfNode(declarator.init, context))
isArrayType(getTypeOfNode(declarator.init, context)) &&
!options.ignoreCollections
? [

@@ -1804,0 +1827,0 @@ {

{
"name": "eslint-plugin-functional",
"version": "3.0.2",
"version": "3.1.0",
"description": "ESLint rules to disable mutation and promote fp in TypeScript.",

@@ -5,0 +5,0 @@ "keywords": [

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