npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stayradiated/eslint-plugin-prefer-arrow-functions

v4.4.0

Published

Convert functions to arrow functions

Downloads

362

Readme

eslint-plugin-prefer-arrow-functions

An ESLint Plugin to Lint and auto-fix plain Functions into Arrow Functions, in all cases where conversion would result in the same behaviour (Arrow Functions do not support this, arguments, or new.target for example).

NPM version NPM downloads Build Status Maintainability

Table of Contents

☁️ Installation

npm install --save-dev eslint eslint-plugin-prefer-arrow-functions

🏓 Playground

Try it yourself at ASTExplorer.net by pasting code snippets in the top left panel, the results will appear in the bottom right panel.

⚖️ Configuration

Add the plugin to the plugins section and the rule to the rules section in your .eslintrc. The default values for options are listed in this example.

{
  "plugins": ["prefer-arrow-functions"],
  "rules": {
    "prefer-arrow-functions/prefer-arrow-functions": [
      "warn",
      {
        "classPropertiesAllowed": false,
        "disallowPrototype": false,
        "returnStyle": "unchanged",
        "singleReturnOnly": false
      }
    ]
  }
}

🤔 Options

classPropertiesAllowed

When true, functions defined as class instance fields will be converted to arrow functions when doing so would not alter or break their behaviour.

disallowPrototype

When true, functions assigned to a prototype will be converted to arrow functions when doing so would not alter or break their behaviour.

returnStyle

  • When "implicit", arrow functions such as x => { return x; } will be converted to x => x.
  • When "explicit", arrow functions such as x => x will be converted to x => { return x; }.
  • When "unchanged" or not set, arrow functions will be left as they were.

singleReturnOnly

When true, only function declarations which only contain a return statement will be converted. Functions containing block statements will be ignored.

This option works well in conjunction with ESLint's built-in arrow-body-style set to as-needed.

👏🏻 Credits

This project is a fork of https://github.com/TristonJ/eslint-plugin-prefer-arrow by Triston Jones.

🙋🏽‍♀️ Getting Help

Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.

👀 Other Projects

If you find my Open Source projects useful, please share them ❤️

  • eslint-formatter-git-logESLint Formatter featuring Git Author, Date, and Hash
  • eslint-plugin-move-filesMove and rename files while keeping imports up to date
  • ImageOptim-CLIAutomates ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of images part of your automated build process.
  • Jasmine-MatchersWrite Beautiful Specs with Custom Matchers
  • karma-benchmarkRun Benchmark.js over multiple Browsers, with CI compatible output
  • self-helpInteractive Q&A Guides for Web and the Command Line
  • syncpackManage multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces

🤓 Author

I'm Jamie Mason from Leeds in England, I began Web Design and Development in 1999 and have been Contracting and offering Consultancy as Fold Left Ltd since 2012. Who I've worked with includes Sky Sports, Sky Bet, Sky Poker, The Premier League, William Hill, Shell, Betfair, and Football Clubs including Leeds United, Spurs, West Ham, Arsenal, and more.

Follow JamieMason on GitHub      Follow fold_left on Twitter