Skip to content

An ESLint plugin that prevent loops usage

License

Notifications You must be signed in to change notification settings

Aperrix/eslint-plugin-loops

Repository files navigation

eslint-plugin-loops

This plugin disallow the usage of for, forOf, forIn, forEach, while and doWhile loops.

Installation

npm i --save-dev eslint-plugin-loops

Usage

// Flat config (eslint >=v8)
import loopsPlugin from "eslint-plugin-loops"
{
    plugins: {
        "loops": loopsPlugin
    },
    rules: {
        "loops/no-loops": ["error"]
    }
}

// Old config
{
    plugins: ["loops"],
    rules: {
        "loops/no-loops": ["error"]
    }
}

Options

You can allow the use of some loops :

{
    rules: {
        "loops/no-loops": [ "error",
            {
                exceptions: ["for", "forOf", "forIn", "forEach", "while", "doWhile"]
            }
        ]
    }
}

About

An ESLint plugin that prevent loops usage

Resources

License

Stars

Watchers

Forks

Packages

No packages published