Package Exports
- eslint-plugin-arrow-return-style
Readme
eslint-plugin-arrow-return-style
Enforce arrow function return style
Features
This rule serves as an alternative to the
arrow-body-style
withas-needed
options, used to improve the style of arrow function return values.
- When arrow function expressions are multiline or exceed a certain length, explicit return should be enforced to improve readability and extensibility.
- When an arrow function has only one return value (and does not contain any comments), implicit return should be used to simplify the code and improve readability.
- When using arrow functions as named exports, explicit return should always be used to maintain consistency with regular functions.
- When using arrow functions as React components, always use explicit return to facilitate the addition of
props
andhooks
in the future.
Install
pnpm add eslint-plugin-arrow-return-style -D
Usage
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['plugin:arrow-return-style/recommended'],
};
Options
maxLen
Type: number
Default: 80
If the arrow function expression exceeds maxLen
characters, it is forced to use explicit return.
Rules
⚠️ Configurations set to warn in.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the --fix
CLI option.
Name | Description | ⚠️ | 🔧 |
---|---|---|---|
arrow-return-style | Enforce arrow function return style | ✅ | 🔧 |