eslint-plugin-fp-jxl
v3.1.0
Published
ESLint rules for functional programming
Downloads
10
Maintainers
Readme
What
ESLint rules for functional programming.
NOTE 1 of 2: This is a fork from https://github.com/jfmengels/eslint-plugin-fp. I looked at the 33 forks at the time and none were up to date. So, I forked it, merged in 2 of the outstanding PR's, and added some missing features (allow class constructors, using classes if you extend React.Component, switch statements that have a default with a return value don't violate fp-jxl/no-nil
, etc).
NOTE 2 of 2: Beware much of the docs will say things like fp-jxl/no-nil
when referring to a rule. Always use that for this library, not fp/no-nil
. The fp-jxl
is the ESLint plugin suffix, and the no-nil
is the rule name. Many places in the documentation and tests refer to fp
. Since I don't own the original package, and ESLint is challenging to configure, just assume fp-jxl/some-rule
for all rules in the documentation, excluding no-var
which is global.
Install
$ npm install --save-dev eslint eslint-plugin-fp-jxl
Usage
Configure it in package.json
.
{
"name": "my-awesome-project",
"eslintConfig": {
"env": {
"es6": true
},
"plugins": [
"fp-jxl"
],
"rules": {
"fp-jxl/explicit-return": "off",
"fp-jxl/must-return": "off",
"fp-jxl/no-arguments": "error",
"fp-jxl/no-class": "error",
"fp-jxl/no-delete": "error",
"fp-jxl/no-events": "error",
"fp-jxl/no-exceptions": "off",
"fp-jxl/no-exports": "off",
"fp-jxl/no-function-expressions": "off",
"fp-jxl/no-get-set": "error",
"fp-jxl/no-ifs": "off",
"fp-jxl/no-imports": "off",
"fp-jxl/no-instanceofs": "off",
"fp-jxl/no-let": "error",
"fp-jxl/no-loops": "error",
"fp-jxl/no-mutating-assign": "error",
"fp-jxl/no-mutating-methods": "error",
"fp-jxl/no-mutation": "error",
"fp-jxl/no-new": "off",
"fp-jxl/no-nil": "error",
"fp-jxl/no-nulls": "off",
"fp-jxl/no-proxy": "error",
"fp-jxl/no-reassigns": "off",
"fp-jxl/no-rest-parameters": "error",
"fp-jxl/no-switches": "off",
"fp-jxl/no-this": "error",
"fp-jxl/no-throw": "error",
"fp-jxl/no-typeofs": "off",
"fp-jxl/no-undefined": "off",
"fp-jxl/no-unused-expression": "error",
"fp-jxl/no-valueof-field": "error",
"fp-jxl/no-variable-declarations": "off",
"no-var": "error"
}
}
}
Rules
- explicit-return - Stricter version of must-return: every function should have a top level return statement.
- must-return - Every branch of every function should have a return statement.
- no-arguments - Forbid the use of
arguments
. - no-class - Forbid the use of
class
. - no-delete - Forbid the use of
delete
. - no-events - Forbid the use of the
events
module. - no-exceptions - Forbids throwing and catching errors.
- no-exports - Forbids use of export keyword
- no-function-expressions - Forbids the use of function expressions, consider: prefer-arrow-callback
- no-get-set - Forbid the use of getters and setters.
- no-ifs - Forbids the use of
if
statements, in favour of ternary expressions - no-imports - Forbids the use of the
import
keyword, in favour of CommonJS - no-instanceofs - Forbids the use of the
instanceof
operator - no-let - Forbid the use of
let
. - no-loops - Forbid the use of loops.
- no-mutating-assign - Forbid the use of
Object.assign()
with a variable as first argument. - no-mutating-methods - Forbid the use of mutating methods.
- no-mutation - Forbid the use of mutating operators.
- no-new - Forbids the use of the
new
keyword - no-nil - Forbid the use of
null
andundefined
. - no-nulls - Forbids the use of
null
. - no-proxy - Forbid the use of
Proxy
. - no-reassigns - Forbids reassigning variables
- no-rest-parameters - Forbid the use of rest parameters.
- no-switches - Forbids the use of the
switch
statement - no-this - Forbid the use of
this
. - no-throw - Forbid the use of
throw
. - no-typeofs - Forbids the typeof operator
- no-undefined - Forbids the use of
undefined
. - no-unused-expression - Enforce that an expression gets used.
- no-valueof-field - Forbid the creation of
valueOf
fields. - no-variable-declarations - Forbids variable declarations, no
var
orlet
.
Recommended configuration
This plugin exports a recommended
configuration that enforces good practices.
To enable this configuration, use the extends
property in your package.json
.
{
"name": "my-awesome-project",
"eslintConfig": {
"plugins": [
"fp"
],
"extends": "plugin:fp-jxl/recommended"
}
}
See ESLint documentation for more information about extending configuration files.
MIT © Jeroen Engels MIT © Ivan Dmitriev MIT © Thomas Grainger MIT © Jesse Warden