New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-arrowsmith

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-arrowsmith

Disallow arrow functions with block parentheses where they are not needed.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45
decreased by-35.71%
Maintainers
1
Weekly downloads
 
Created
Source

Arrow functions with a block body containing only a single return statement or a single expression statement can be simplified by removing the braces and, in the case of a return statement, the return keyword. This simplification can improve code readability.

Rule Details

This rule aims to report and fix arrow functions that can have their block body simplified.

Examples of incorrect code for this rule:

/* eslint no-useless-arrow-block: "error" */

const foo = () => { return 5; };

const bar = (x) => { return x * 2; };

const baz = () => { console.log('Hello'); };

const qux = (a, b) => {
  return a + b;
};

Examples of correct code for this rule:

/* eslint no-useless-arrow-block: "error" */

const foo = () => 5;

const bar = (x) => x * 2;

const baz = () => console.log('Hello');

const qux = (a, b) => a + b;

const complex = () => {
  doSomething();
  return result;
};

const multiLine = () => (
  veryLongExpression +
  thatNeedsToBeWrapped
);

class MyClass {
  static myMethod = () => {
    this.doSomething();
  };
}

When Not To Use It

If you prefer consistency in all arrow function bodies using blocks, you can disable this rule. Also, if you use arrow functions with a single statement that you prefer to keep in block form for potential future expansion, you might want to disable this rule.

Keywords

FAQs

Package last updated on 07 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc