Socket
Socket
Sign inDemoInstall

eslint-plugin-functional

Package Overview
Dependencies
215
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

8

lib/index.js

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

if (node === void 0) { node = null; }
return assumeType === true
return assumeType === true && type === null
? node !== null

@@ -301,3 +301,3 @@ : type !== null &&

if (node === void 0) { node = null; }
return assumeType === true
return assumeType === true && type === null
? node !== null && isIdentifier(node) && node.name === "Array"

@@ -312,3 +312,3 @@ : type !== null &&

if (node === void 0) { node = null; }
return assumeType === true
return assumeType === true && type === null
? node !== null && isIdentifier(node) && node.name === "Object"

@@ -575,3 +575,3 @@ : type !== null &&

const version = "1.0.0-rc.2";
const version = "1.0.0";

@@ -578,0 +578,0 @@ // This function can't be functional as it needs to interact with 3rd-party

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

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -17,3 +17,3 @@ # eslint-plugin-functional

We've identified the following areas that needs to be linted in order to promote functional style in TypeScript/JavaScript:
We've identified the following areas that need to be linted in order to promote functional style in TypeScript/JavaScript:

@@ -28,7 +28,7 @@ - [No mutations](#no-mutations)

In some applications it is important to not mutate any data, for example when using Redux to store state in a React application. Moreover immutable data structures has a lot of advantages in general so I want to use them everywhere in my applications.
In some applications it is important to not mutate any data, for example when using Redux to store state in a React application. Moreover immutable data structures have a lot of advantages in general so I want to use them everywhere in my applications.
I originally used [immutablejs](https://github.com/facebook/immutable-js/) for this purpose. It is a really nice library but I found it had some drawbacks. Specifically when debugging it was hard to see the structure, creating JSON was not straightforward, and passing parameters to other libraries required converting to regular mutable arrays and objects. The [seamless-immutable](https://github.com/rtfeldman/seamless-immutable) project seems to have the same conclusions and they use regular objects and arrays and check for immutability at run-time. This solves all the aformentioned drawbacks but introduces a new drawback of only being enforced at run-time. (Altough you lose the structural sharing feature of immutablejs with this solution so you would have to consider if that is something you need).
I originally used [immutablejs](https://github.com/facebook/immutable-js/) for this purpose. It is a really nice library but I found it had some drawbacks. Specifically when debugging it was hard to see the structure, creating JSON was not straightforward, and passing parameters to other libraries required converting to regular mutable arrays and objects. The [seamless-immutable](https://github.com/rtfeldman/seamless-immutable) project seems to have the same conclusions and they use regular objects and arrays and check for immutability at run-time. This solves all the aformentioned drawbacks but introduces a new drawback of only being enforced at run-time. (Although you lose the structural sharing feature of immutablejs with this solution so you would have to consider if that is something you need).
Then TypeScript 2.0 came along and introduced [readonly](https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#read-only-properties-and-index-signatures) options for properties, indexers and arrays. TypeScript 3.0 has continued to add support immutability enforcing syntax. This enables us to use regular object and arrays and have the immutability enforced at compile time instead of run-time. Now the only drawback is that there is nothing enforcing the use of readonly in TypeScript.
Then TypeScript 2.0 came along and introduced [readonly](https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#read-only-properties-and-index-signatures) options for properties, indexers and arrays. TypeScript 3.0 has continued to add support immutability enforcing syntax. This enables us to use regular objects and arrays and have the immutability enforced at compile time instead of run-time. Now the only drawback is that there is nothing enforcing the use of readonly in TypeScript.

@@ -39,3 +39,3 @@ This can be solved by using linting rules. So one aim of this project is to leverage the type system in TypeScript to enforce immutability at compile-time while still using regular objects and arrays. Additionally, this project will also aim to support disabling mutability for vanilla JavaScript where possible.

JavaScript is multi-paradigm, allowing both object-oriented and functional programming styles. In order to promote a functional style, the object oriented features of JavaScript needs to be disabled.
JavaScript is multi-paradigm, allowing both object-oriented and functional programming styles. In order to promote a functional style, the object oriented features of JavaScript need to be disabled.

@@ -82,3 +82,3 @@ ### No statements

There are several rulesets provided by this plugin.
[See bellow](#supported-rules) for what they are and what rules are including in each.
[See below](#supported-rules) for what they are and what rules are including in each.

@@ -125,3 +125,3 @@ You can enable one of these rulesets like so:

| :thought_balloon: | Only Avaliable for TypeScript<br><sub><sup>The rule either requires Type Information or only works with TypeScript syntax.</sup></sub> |
| :blue_heart: | Works better with TypeScript<br><sub><sup>Type Information will be used if available making the rule work in more case.</sup></sub> |
| :blue_heart: | Works better with TypeScript<br><sub><sup>Type Information will be used if available making the rule work in more cases.</sup></sub> |

@@ -159,3 +159,3 @@ ### No Mutations Rules

| [`no-loop-statement`](./docs/rules/no-loop-statement.md) | Disallow imperative loops | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| [`no-return-void`](./docs/rules/no-return-void.md) | Disallow function that return nothing | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :thought_balloon: |
| [`no-return-void`](./docs/rules/no-return-void.md) | Disallow functions that return nothing | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :thought_balloon: |

@@ -182,3 +182,3 @@ ### No Exceptions Rules

In addition to the immutability rules above, there are a few standard rules that needs to be enabled to achieve immutability.
In addition to the immutability rules above, there are a few standard rules that need to be enabled to achieve immutability.

@@ -201,3 +201,3 @@ Each of these rules are enabled by default in the rulesets this plugin provides.

For performance reasons, tslint-immutable does not check implicit return types. So for example this function will return an mutable array but will not be detected:
For performance reasons, eslint-plugin-functional does not check implicit return types. So for example this function will return a mutable array but will not be detected:

@@ -220,3 +220,3 @@ ```js

To learn about eslint plugin development se the [relevant section](https://eslint.org/docs/developer-guide/working-with-plugins) of the eslit docs. You can also checkout the [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) repo which has some more information specific to typescript.
To learn about eslint plugin development see the [relevant section](https://eslint.org/docs/developer-guide/working-with-plugins) of the eslint docs. You can also checkout the [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) repo which has some more information specific to typescript.

@@ -223,0 +223,0 @@ In order to know which AST nodes are created for a snippet of TypeScript code you can use [ast explorer](https://astexplorer.net/) with options JavaScript and @typescript-eslint/parser.

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