https://github.com/prettier/tslint-plugin-prettier
Runs Prettier as a TSLint rule and reports differences as individual TSLint issues
https://github.com/prettier/tslint-plugin-prettier
prettier tslint tslint-plugin tslint-rules
Last synced: 7 months ago
JSON representation
Runs Prettier as a TSLint rule and reports differences as individual TSLint issues
- Host: GitHub
- URL: https://github.com/prettier/tslint-plugin-prettier
- Owner: prettier
- License: mit
- Created: 2017-07-30T07:49:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T07:01:20.000Z (about 3 years ago)
- Last Synced: 2025-05-07T04:33:39.491Z (8 months ago)
- Topics: prettier, tslint, tslint-plugin, tslint-rules
- Language: TypeScript
- Homepage:
- Size: 582 KB
- Stars: 235
- Watchers: 7
- Forks: 14
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tslint-plugin-prettier
[](https://www.npmjs.com/package/tslint-plugin-prettier)
[](https://travis-ci.org/prettier/tslint-plugin-prettier/builds)
[](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 `/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)