@babel/plugin-transform-inline-consecutive-adds

Example

In

  1. const foo = {};
  2. foo.a = 42;
  3. foo.b = ["hi"];
  4. foo.c = bar();
  5. foo.d = "str";
  6. ...
  7. const bar = [];
  8. bar.push(1);
  9. bar.push(2);

Out

  1. const foo = {
  2. a: 42,
  3. b: ["hi"],
  4. c: bar(),
  5. d: "str"
  6. };
  7. ...
  8. const bar = [1, 2];

Installation

  1. npm install babel-plugin-transform-inline-consecutive-adds --save-dev

Usage

.babelrc

  1. {
  2. "plugins": ["transform-inline-consecutive-adds"]
  3. }

Via CLI

  1. babel --plugins transform-inline-consecutive-adds script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["transform-inline-consecutive-adds"]
  3. });