This plugin disallow the usage of for
, forOf
, forIn
, forEach
, while
and doWhile
loops.
npm i --save-dev eslint-plugin-loops
// 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"]
}
}
You can allow the use of some loops :
{
rules: {
"loops/no-loops": [ "error",
{
exceptions: ["for", "forOf", "forIn", "forEach", "while", "doWhile"]
}
]
}
}