Home

Awesome

eslint-plugin-pure

Enforce rules to make your code purely functional by disallowing some language constructs.

Note: Your code must be using ES6 modules, because module.exports = is considered impure code!

What are disallowed?

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-pure:

$ npm install purely-functional/eslint-plugin-pure --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-pure globally.

Usage

Add pure to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

plugins:
  - pure

Then in the files you want to make pure, put this comment in:

/* eslint pure/pure: 2 */

Use these built-in recommended rules. These rules are useful outside of pure code but when used in conjunction with this plugin yields a powerful effect:

rules:
  no-var: 2
  prefer-const: 2
  no-undef: 2
  no-unused-vars: 2

Also look into eslint-plugin-immutable for even more enforcement (such as disallowing this).

Should I use this everywhere?

Probably not. I recommend using this in your reducers or in entity modules.

Supported Rules