eslint-plugin-no-multiple-returns
v1.1.0
Published
An ESLint plugin to enforce a single `return` statement per function, encouraging clearer and more maintainable code.
Maintainers
Readme
eslint-plugin-no-multiple-returns
An ESLint plugin to enforce a single return statement per function, encouraging clearer and more maintainable code.
📦 Installation
npm install --save-dev eslint-plugin-no-multiple-returns🔧 Usage
Add no-multiple-returns to your ESLint configuration:
{
"plugins": ["no-multiple-returns"],
"rules": {
"no-multiple-returns/no-multiple-returns": "error"
}
}✅ Rule Details
This rule disallows functions that contain more than one return statement.
🔍 Examples of correct code:
function singleReturn() {
return 1;
}
const fn = () => {
return 42;
};
const concise = () => 123;❌ Examples of incorrect code:
function bad(x) {
if (x) return 1;
return 2;
}
const multipleReturns = () => {
if (a) return 1;
return 2;
};🧪 Development
npm install
npm run build
npm test📄 License
MIT
