# lua-fmt

> Format Lua code

Latest version **2.6.0** (published 2018-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install lua-fmt
pnpm add lua-fmt
yarn add lua-fmt
bun add lua-fmt
```

Provides the command `luafmt`.

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.6.0 |
| Published | 2018-03-11 |
| First published | 2017-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 111.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 197 |
| Author | trixnz |
| Maintainers | trixnz |
| Keywords | lua, format, lua-fmt, formatter |

## Links

- npm: https://www.npmjs.com/package/lua-fmt
- Repository: https://github.com/trixnz/lua-fmt
- Issues: https://github.com/trixnz/lua-fmt/issues
- npm.io page: https://npm.io/package/lua-fmt

## Dependencies (7)

- [diff](https://npm.io/package/diff.md) ^3.3.0
- [luaparse](https://npm.io/package/luaparse.md) github:oxyc/luaparse#ac42a00ebf4020b8c9d3219e4b0f84bf7ce6e802
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [get-stdin](https://npm.io/package/get-stdin.md) ^5.0.1
- [@types/diff](https://npm.io/package/@types/diff.md) ^3.2.0
- [@types/commander](https://npm.io/package/@types/commander.md) ^2.3.31
- [@types/get-stdin](https://npm.io/package/@types/get-stdin.md) ^5.0.0

## 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

- 2.6.0 (latest) — 2018-03-11
- 2.5.0 — 2017-12-11
- 2.4.0 — 2017-10-17
- 2.3.0 — 2017-07-18
- 2.2.0 — 2017-05-28
- 2.1.2 — 2017-04-15
- 2.1.0 — 2017-04-13
- 2.0.1 — 2017-03-21
- 2.0.0 — 2017-03-21
- 1.0.0 — 2017-03-07

## README

[![Build Status](https://travis-ci.org/trixnz/lua-fmt.svg?branch=master)](https://travis-ci.org/trixnz/lua-fmt) [![NPM Package](https://img.shields.io/npm/v/lua-fmt.svg)](https://www.npmjs.com/package/lua-fmt)

# Code Formatter for Lua
`lua-fmt` is pretty-printer for [Lua](https://www.lua.org/) code, written in [TypeScript](https://www.typescriptlang.org/) and deeply inspired by [prettier](https://github.com/prettier/prettier). `lua-fmt` provides an interface to format Lua code that conforms to a single and consistent standard.

While not implemented yet, the interface will be customizable to tailor the output to the user's preferences: linebreaks, string style, etc.

## Installing
* `npm install lua-fmt`

## Usage
### API
```TypeScript
import {formatText} from 'lua-fmt';
console.log(formatText('local hello = "Hello"; print(hello .. " world!")'))
```

### Command Line
Format a single file:
* `luafmt test/lua-5.3.4-tests/calls.lua`

Format a stream from `stdin`:
* `cat test/lua-5.3.4-tests/calls.lua | luafmt --stdin`

## TODO
- [ ] Add support for a `.luafmt` preferences file

## Testing
`lua-fmt` uses [jest](https://facebook.github.io/jest/) for automated testing.

Among the user-created tests in the `test/` folder, a copy of the `lua-5.3.4` tests are executed after formatting to ensure the code remains syntactically correct after formatting. For this reason, please do not modify the `lua-5.3.4-tests` folder unless updating with new tests from the official Lua tests. To run these tests, `lua53` is expected to be available on the `PATH`.

When contributing changes, please consider writing tests to ensure they do not regress.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments
* [Oskar Schöldström](https://github.com/oxyc) - [luaparse](https://github.com/oxyc/luaparse): A Lua parser written in JavaScript
* [Christopher Chedeau](https://github.com/vjeux) - [prettier](https://github.com/prettier/prettier): Prettier is an opinionated JavaScript formatter.
* [Ben Newman](https://github.com/benjamn) - [recast](https://github.com/benjamn/recast): JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator.

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