# babel-plugin-syntax-trailing-function-commas

> Compile trailing function commas to ES5

Latest version **6.22.0** (published 2017-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-syntax-trailing-function-commas
pnpm add babel-plugin-syntax-trailing-function-commas
yarn add babel-plugin-syntax-trailing-function-commas
bun add babel-plugin-syntax-trailing-function-commas
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score; popular repo.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 6.22.0 |
| Published | 2017-01-20 |
| First published | 2015-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43996 |
| Maintainers | amasad, hzoo, jmm, loganfsmyth, sebmck, thejameskyle |
| Keywords | babel-plugin |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-syntax-trailing-function-commas
- Repository: https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-trailing-function-commas
- npm.io page: https://npm.io/package/babel-plugin-syntax-trailing-function-commas

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 6.22.0 (latest) — 2017-01-20
- 7.0.0-beta.0 (next) — 2017-09-12
- 7.0.0-alpha.20 — 2017-08-30
- 7.0.0-alpha.19 — 2017-08-07
- 7.0.0-alpha.18 — 2017-08-03
- 7.0.0-alpha.17 — 2017-07-26
- 7.0.0-alpha.16 — 2017-07-25
- 7.0.0-alpha.15 — 2017-07-12
- 7.0.0-alpha.14 — 2017-07-12
- 7.0.0-alpha.13 — 2017-07-12
- 7.0.0-alpha.12 — 2017-05-31
- 7.0.0-alpha.11 — 2017-05-31
- 7.0.0-alpha.10 — 2017-05-25
- 7.0.0-alpha.9 — 2017-04-18
- 7.0.0-alpha.8 — 2017-04-17
- … 19 more at https://npm.io/package/babel-plugin-syntax-trailing-function-commas/versions

## README

# babel-plugin-syntax-trailing-function-commas

Compile trailing function commas to ES5


```js
function clownPuppiesEverywhere(
  param1,
  param2,
) { /* ... */ }

clownPuppiesEverywhere(
  'foo',
  'bar',
);
```
[Try in REPL](http://babeljs.io/repl/#?evaluate=true&presets=es2015%2Cstage-0&code=function%20clownPuppiesEverywhere(%0A%20%20param1%2C%0A%20%20param2%2C%0A)%20%7B%20%2F*%20...%20*%2F%20%7D%0A%0AclownPuppiesEverywhere(%0A%20%20'foo'%2C%0A%20%20'bar'%2C%0A)%3B)

## Example

### Basic
This is an example from the [Proposal](https://github.com/jeffmo/es-trailing-function-commas).

Let's say you have this function:

```js
function clownPuppiesEverywhere(
  param1,
  param2
) { /* ... */ }

clownPuppiesEverywhere(
  'foo',
  'bar'
);
```

If you want to have a new parameter called `param3`, the diff output would be like that:

```diff
function clownPuppiesEverywhere(
  param1,
- param2
+ param2, // Change this line to add a comma
+ param3  // Add param3
) { /* ... */ }

clownPuppiesEverywhere(
  'foo',
- 'bar'
+ 'bar', // Change this line to add a comma
+ 'baz'  // Add param3
);
```
In total, you have to change 2 lines for the function declaration and 2 lines for each usage.

If you had your function defined with trailing commas:

```js
function clownPuppiesEverywhere(
  param1,
  param2,
) { /* ... */ }

clownPuppiesEverywhere(
  'foo',
  'bar',
);
```
Adding a new parameter would only change one line in the function declaration and one line for each usage:

```diff
function clownPuppiesEverywhere(
  param1,
  param2,
+ param3, // Add param3
) { /* ... */ }

clownPuppiesEverywhere(
  'foo',
  'bar',
+ 'baz', // Add param3
);
```
In the end, your diff output will be cleaner and easier to read, it would be much quicker to add a new parameter to your functions, it also makes it easier to copy paste elements and move code around.

## Installation

```sh
npm install --save-dev babel-plugin-syntax-trailing-function-commas
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
  "plugins": ["syntax-trailing-function-commas"]
}
```

### Via CLI

```sh
babel --plugins syntax-trailing-function-commas script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
  plugins: ["syntax-trailing-function-commas"]
});
```

## References

* [Proposal](https://github.com/jeffmo/es-trailing-function-commas)
* [Spec](http://jeffmo.github.io/es-trailing-function-commas/)
* [Why you should enforce Dangling Commas for Multiline Statements](https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8)

---
_Source: https://npm.io/package/babel-plugin-syntax-trailing-function-commas · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
