eslint-plugin-cleanjs
v0.0.1
Published
ESLint rules for functional programming
Downloads
5
Maintainers
Readme
eslint-plugin-cleanjs
ESLint rules for functional programming
Install
$ npm install --save-dev eslint eslint-plugin-cleanjs
Usage
Configure it in package.json
.
{
"name": "my-awesome-project",
"eslintConfig": {
"env": {
"es6": true
},
"plugins": [
"cleanjs"
],
"rules": {
"cleanjs/explicit-return": "off",
"cleanjs/must-return": "error",
"cleanjs/no-arguments": "error",
"cleanjs/no-class": "error",
"cleanjs/no-delete": "error",
"cleanjs/no-events": "error",
"cleanjs/no-exceptions": "off",
"cleanjs/no-exports": "off",
"cleanjs/no-function-expressions": "off",
"cleanjs/no-get-set": "error",
"cleanjs/no-ifs": "error",
"cleanjs/no-imports": "off",
"cleanjs/no-instanceofs": "error",
"cleanjs/no-let": "error",
"cleanjs/no-loops": "error",
"cleanjs/no-mutating-assign": "error",
"cleanjs/no-mutating-methods": "error",
"cleanjs/no-mutation": "error",
"cleanjs/no-new": "error",
"cleanjs/no-nil": [
"error",
{
"explicitReturn": false
}
],
"cleanjs/no-nulls": "off",
"cleanjs/no-proxy": "error",
"cleanjs/no-reassigns": "off",
"cleanjs/no-rest-parameters": "error",
"cleanjs/no-switches": "off",
"cleanjs/no-this": "error",
"cleanjs/no-throw": "error",
"cleanjs/no-typeofs": "off",
"cleanjs/no-undefined": "off",
"cleanjs/no-unused-expression": "error",
"cleanjs/no-valueof-field": "error",
"cleanjs/no-variable-declarations": "off",
"no-var": "error",
"prefer-spread": "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": [
"cleanjs"
],
"extends": "plugin:cleanjs/recommended"
}
}
See ESLint documentation for more information about extending configuration files.
Thanks
- With inspiration and recommended rule-set from:
- https://github.com/bodil/eslint-config-cleanjs
- Code from:
- https://github.com/jfmengels/eslint-plugin-fp
- https://github.com/imitrieve/eslint-plugin-better
MIT © Jeroen Engels MIT © Ivan Dmitriev MIT © Thomas Grainger