# prettier-hook

> The library allows to modify the AST before executing Prettier.

Latest version **0.5.1** (published 2020-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-hook
pnpm add prettier-hook
yarn add prettier-hook
bun add prettier-hook
```

Provides the command `prettier-hook`.

## 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.5.1 |
| Published | 2020-04-14 |
| First published | 2018-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 24.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Suguru Motegi |
| Maintainers | suguru03 |

## Links

- npm: https://www.npmjs.com/package/prettier-hook
- Homepage: https://github.com/suguru03/prettier-hook
- npm.io page: https://npm.io/package/prettier-hook

## Dependencies (2)

- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [vm-agent](https://npm.io/package/vm-agent.md) ^0.6.0

## Recent versions

- 0.5.1 (latest) — 2020-04-14
- 0.5.0 — 2020-04-14
- 0.4.6 — 2019-12-04
- 0.4.5 — 2019-04-01
- 0.4.4 — 2019-04-01
- 0.4.3 — 2019-03-22
- 0.4.2 — 2019-03-22
- 0.4.1 — 2019-03-22
- 0.4.0 — 2019-03-18
- 0.3.2 — 2019-02-19
- 0.3.1 — 2019-02-19
- 0.3.0 — 2019-02-19
- 0.2.0 — 2018-12-29
- 0.1.2 — 2018-11-19
- 0.1.1 — 2018-11-19
- … 1 more at https://npm.io/package/prettier-hook/versions

## README

# Prettier Hook

The library allows to modify the AST before executing Prettier.

```js
const { hooks } = require('prettier-hook');

function parse(ast) {
  // modify AST
  return ast;
}

hooks.typescript.addHook(parse);
```

```sh
npx prettier-hook --require <filepath>
// or
yarn prettier-hook --require <filepath>
```
## Example

There is an example which is converting require to import.

```js
// examples/simple/test.js
const fs = require('fs');
```

```
$ DEBUG=1 yarn ts-node dist/bin/prettier-hook.js --require examples/simple/index.ts examples/simple/test.js
```

```js
// examples/simple/test.js
import * as fs from 'fs';
```

## Use case

- [javascript2typescript](https://github.com/suguru03/javascript2typescript)
- [typeg](https://github.com/suguru03/typeg)

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