# tslint-plugin-prettier

> Runs Prettier as a TSLint rule and reports differences as individual TSLint issues.

Latest version **2.3.0** (published 2020-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install tslint-plugin-prettier
pnpm add tslint-plugin-prettier
yarn add tslint-plugin-prettier
bun add tslint-plugin-prettier
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2020-03-26 |
| First published | 2017-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 3 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 231 |
| Author | Ika |
| Maintainers | ikatyang |
| Keywords | prettier, tslint, tslint-plugin, tslint-rules |

## Links

- npm: https://www.npmjs.com/package/tslint-plugin-prettier
- Repository: https://github.com/prettier/tslint-plugin-prettier
- Homepage: https://github.com/prettier/tslint-plugin-prettier#readme
- Issues: https://github.com/prettier/tslint-plugin-prettier/issues
- npm.io page: https://npm.io/package/tslint-plugin-prettier

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^1.7.1
- [lines-and-columns](https://npm.io/package/lines-and-columns.md) ^1.1.6
- [eslint-plugin-prettier](https://npm.io/package/eslint-plugin-prettier.md) ^2.2.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 2.3.0 (latest) — 2020-03-26
- 3.0.0-beta.0 (next) — 2020-04-21
- 2.2.0 — 2020-03-14
- 2.1.0 — 2019-12-21
- 2.0.1 — 2018-10-28
- 2.0.0 — 2018-09-16
- 1.3.0 — 2017-09-28
- 1.2.0 — 2017-09-15
- 1.1.0 — 2017-08-16
- 1.0.0 — 2017-07-30

## README

# tslint-plugin-prettier

[![npm](https://img.shields.io/npm/v/tslint-plugin-prettier.svg)](https://www.npmjs.com/package/tslint-plugin-prettier)
[![build](https://img.shields.io/travis/prettier/tslint-plugin-prettier/master.svg)](https://travis-ci.org/prettier/tslint-plugin-prettier/builds)
[![coverage](https://img.shields.io/codecov/c/github/prettier/tslint-plugin-prettier/master.svg)](https://codecov.io/gh/prettier/tslint-plugin-prettier)

Runs Prettier as a TSLint rule and reports differences as individual TSLint issues.

[Changelog](https://github.com/prettier/tslint-plugin-prettier/blob/master/CHANGELOG.md)

## Sample

```ts
a();;;
    ~~
;;;
~~~ [Delete `;;⏎;;;`]
```

```ts
var foo = ''
          ~~ [Replace `''` with `"";⏎`]
```

```ts
var foo= "";
       ~ [Insert `·`]
```

## Install

```sh
# using npm
npm install --save-dev tslint-plugin-prettier prettier

# using yarn
yarn add --dev tslint-plugin-prettier prettier
```

(require `prettier@^1.9.0`)

## Usage

(tslint.json)

for `tslint@^5.2.0`

```json
{
  "rulesDirectory": ["tslint-plugin-prettier"],
  "rules": {
    "prettier": true
  }
}
```

for `tslint@^5.0.0`

```json
{
  "extends": ["tslint-plugin-prettier"],
  "rules": {
    "prettier": true
  }
}
```

**NOTE**: To use this plugin, it'd better to also use [tslint-config-prettier](https://github.com/prettier/tslint-config-prettier) to disable all prettier-related rules, so as to avoid conflicts between existed rules.

## Options

- If there is no option provided, it'll try to load [config file](https://prettier.io/docs/en/configuration.html) and/or `.editorconfig` if possible, uses Prettier's default option if not found.

  ```json
  {
    "extends": ["tslint-plugin-prettier"],
    "rules": {
      "prettier": true
    }
  }
  ```

  If you don't want to load `.editorconfig`, disable it in the third argument.

  ```json
  {
    "extends": ["tslint-plugin-prettier"],
    "rules": {
      "prettier": [true, null, { "editorconfig": false }]
    }
  }
  ```

- If you'd like to specify which config file to use, just put its path (relative to `process.cwd()`) in the second argument, the following example shows how to load the config file from `<cwd>/configs/.prettierrc`:

  ```json
  {
    "extends": ["tslint-plugin-prettier"],
    "rules": {
      "prettier": [true, "configs/.prettierrc"]
    }
  }
  ```

- If you'd like to specify options manually, just put [Prettier Options](https://prettier.io/docs/en/options.html) in the second argument, for example:

  ```json
  {
    "extends": ["tslint-plugin-prettier"],
    "rules": {
      "prettier": [true, { "singleQuote": true }]
    }
  }
  ```

## Ignoring files

- It will respect your .prettierignore file in your project root ( process.cwd() ) but if you would like to use a different file you can provide it in the third argument, for example:

  ```json
  {
    "extends": ["tslint-plugin-prettier"],
    "rules": {
      "prettier": [true, null, { "ignorePath": "otherDirectory/.prettierignore" }]
    }
  }

  ```

## Development

```sh
# lint
yarn run lint

# build
yarn run build

# test
yarn run test
```

## Related

- [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier)
- [tslint-config-prettier](https://github.com/prettier/tslint-config-prettier)
- [prettier-tslint](https://github.com/azz/prettier-tslint)

## License

MIT © [Ika](https://github.com/ikatyang)

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