JSPM

eslint-plugin-arrow-return-style

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17911
  • Score
    100M100P100Q145322F
  • License MIT

Enforce arrow function return style

Package Exports

  • eslint-plugin-arrow-return-style

Readme

eslint-plugin-arrow-return-style

Enforce arrow function return style

npm version npm downloads codecov

Features

This rule serves as an alternative to the arrow-body-style with as-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 and hooks 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 🔧

License

MIT License © 2023 u3u