# dbt-formatter

> DBT jinja/sql formatter

Latest version **1.3.0** (published 2020-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install dbt-formatter
pnpm add dbt-formatter
yarn add dbt-formatter
bun add dbt-formatter
```

Provides the command `dbt-formatter`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2020-05-28 |
| First published | 2019-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10.0.0 |
| Dependencies | 3 |
| Unpacked size | 2.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 47 |
| Author | Henri Blancke |
| Maintainers | henriblancke |
| Keywords | dbt, formatter, jinja, sql |

## Links

- npm: https://www.npmjs.com/package/dbt-formatter
- Repository: https://github.com/henriblancke/dbt-formatter
- Homepage: https://github.com/henriblancke/dbt-formatter#readme
- Issues: https://github.com/henriblancke/dbt-formatter/issues
- npm.io page: https://npm.io/package/dbt-formatter

## Dependencies (3)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [commander](https://npm.io/package/commander.md) ^5.1.0

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2020-05-28
- 1.2.0 — 2020-02-24
- 1.1.2 — 2019-08-22
- 1.1.1 — 2019-08-22
- 1.0.3 — 2019-06-15
- 1.0.2 — 2019-06-11
- 1.0.1 — 2019-06-11
- 1.0.0 — 2019-06-11

## README

[![CircleCI](https://circleci.com/gh/henriblancke/dbt-formatter/tree/master.svg?style=svg)](https://circleci.com/gh/henriblancke/dbt-formatter/tree/master)

# DBT Formatter

### Install

```bash
npm install -s dbt-formatter
```

### Usage

```javascript
import formatter from 'dbt-formatter';

const mySql = "SELECT * FROM {{ ref('myTableRef') }}";
const myOpts = { sql: 'default', indent: 2, upper: false };

formatter.format(mySql, myOpts);
```

This will result in:

```sql
SELECT
  *
FROM
  {{ ref('myTableRef') }}
```

### Usage options

Fine tune `dbt-formatter` behavior with the following options:

| Option         | Default   | Description                                                            |
| -------------- | --------- | ---------------------------------------------------------------------- |
| sql            | `default` | The sql dialect you want to use, currently only `default` is available |
| indent         | `2`       | How many spaces you want an indentation to be                          |
| upper          | `false`   | Formats sql reserved words to be uppercase when set to `true`          |
| newline        | `false`   | Appends a new line at the end of the formatted sql string              |
| lowerWords     | `false`   | Lowercases all `words` as identified by the tokenizer                  |
| allowCamelcase | `true`    | Allows column names to be camelcased                                   |

## Development

### NPM scripts

- `npm test`: Run test suite
- `npm start`: Run `npm run build` in watch mode
- `npm run build`: Generate bundles and typings, create docs
- `npm run lint`: Lints code
- `npm run package`: Package dbt-formatter as a binary

## Roadmap

- Add more sql dialects:
  - [x] snowflake
  - [ ] redshift
  - [ ] bigquery
  - [ ] postgres
  - [ ] presto

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