eslint-plugin-complex-logic

0.3.1 • Public • Published

eslint-plugin-complex-logic

npm version

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.3.176latest

Version History

VersionDownloads (Last 7 Days)Published
0.3.176
0.3.00
0.2.10

Package Sidebar

Install

npm i eslint-plugin-complex-logic

Weekly Downloads

76

Version

0.3.1

License

MIT

Unpacked Size

4.75 kB

Total Files

4

Last publish

Collaborators

  • tomyam2020