eslint-plugin-complex-logic
v0.3.1
Published
ESLint rule to check the complexity of logical expressions
Downloads
343
Maintainers
Readme
eslint-plugin-complex-logic
This rule checks the number of logical operators in a conditional expression to see its complexity.
/* eslint complex-logic/complex-logic: ["error", 4] */
// incorrect
if (true && true && true && true && true && true) {
}
const foo = true && true && true && true && true && true ? 1 : 0;
// correct
if (true && true && true && true && true) {
}
const bar = true && true && true && true && true ? 1 : 0;
Installation
npm
npm install --save-dev eslint-plugin-complex-logic
yarn
yarn add -D eslint-plugin-complex-logic
Usage
The rule takes one option, which is the maximum allowed number of logical operators in an expression. The default is 4.
You can set the option like this in .eslintrc.js
:
module.exports = {
plugins: ["complex-logic"],
rules: {
"complex-logic/complex-logic": ["error", 4],
},
};
License
MIT