# esfmt

> Javascript formatter library

Latest version **0.0.15** (published 2016-03-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install esfmt
pnpm add esfmt
yarn add esfmt
bun add esfmt
```

Provides the command `esfmt`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2016-03-05 |
| First published | 2015-09-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Maintainers | dmitriiabramov |
| Keywords | pretty print, format, beautifier, beautify, esfmt |

## Links

- npm: https://www.npmjs.com/package/esfmt
- Repository: https://github.com/dmitriiabramov/esfmt
- Homepage: https://github.com/dmitriiabramov/esfmt#readme
- Issues: https://github.com/dmitriiabramov/esfmt/issues
- npm.io page: https://npm.io/package/esfmt

## Dependencies (3)

- [espree](https://npm.io/package/espree.md) ^2.2.5
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.3.19
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.3.14

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.15 (latest) — 2016-03-05
- 0.0.13 — 2015-12-29
- 0.0.12 — 2015-12-29
- 0.0.11 — 2015-09-16
- 0.0.10 — 2015-09-16
- 0.0.8 — 2015-09-13
- 0.0.7 — 2015-09-12
- 0.0.6 — 2015-09-12
- 0.0.5 — 2015-09-11
- 0.0.4 — 2015-09-11
- 0.0.3 — 2015-09-11
- 0.0.2 — 2015-09-11
- 0.0.1 — 2015-09-05

## README

[![Build Status](https://travis-ci.org/dmitriiabramov/esfmt.svg?branch=master)](https://travis-ci.org/dmitriiabramov/esfmt)
[![codecov.io](http://codecov.io/github/dmitriiabramov/esfmt/coverage.svg?branch=master)](http://codecov.io/github/dmitriiabramov/esfmt?branch=master)
[![npm version](https://badge.fury.io/js/esfmt.svg)](https://badge.fury.io/js/esfmt)


esfmt formats (beautifies, pretty-prints) javascript (es6, jsx) code.


## Install
```
npm install -g esfmt
```

## CLI
```
Usage:
   esfmt [flags] [files ...]

Options:
   -w          | overwrite contents of the files with formatted version
   --help      | print this text
   --version   | print esfmt version

Without an explicit path, esfmt will process stdin and print results to stdout
```


## Example
```js
// echo 'if((a + b) * 4){return (e) => { return a.b.c(<Component a="5" b={[1, b, 0]}><br /></Component>)}} else { return {a: 5, b: 8, c: 9} }' | ./bin/esfmt
if ((a + b) * 4) {
    return (e) => {
        return a.b.c(<Component a="5" b={[1, b, 0]}>
            <br />
        </Component>);
    };
} else {
    return {
        a: 5,
        b: 8,
        c: 9
    };
}
```

## Development

#### Testing
Most of the testing is done by formatting code snippets and matching resulting output with expected string value.

Code snippet files are located at `test/code_snippets/*.js`

The DSL has the following format

```js
// input: test case description (e.g. variable declaration)
let a        =         5;
// output:
let a = 5;
```

this will produce a test case that will look like this:
```
code snippets
    ✓ code_snippets_filename: test case description (e.g. variable declaration)
```

if any specific test needs to be whitelisted (mocha it.only) or blacklisted (mocha it.skip) skip or only line can be added after the test description
```js
// input: arrays
// skip
[1, 'a', null];
// output:
[1, 'a', null];
```

or

```js
// input: arrays
// only
[1, 'a', null];
// output:
[1, 'a', null];
```

in addition to that, if any specific configuration values need to be used for the test, they can be passed using a config line `// config: {"settingName": "value"}`

Note that the values should be provided in JSON format (meaning double quotes around the keys)
```js
// input: arrays
// only
// config: {"max-len": 5}
[1, 'a', null];
// output:
[1, 'a', null];
```


#### TODO
- CLI
- comments in
    - class definitions
    - arguments (lists)

---
_Source: https://npm.io/package/esfmt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
