josephfrazier/prettier_d


eslint_d for prettier! Forked from https://github.com/mantoni/eslint_d.js

https://npm.im/prettier_d

License: MIT

Language: JavaScript


prettier_d

Build Status SemVer License

Makes prettier the fastest formatter on the planet.

Table of Contents

"But prettier is pretty fast already, right?"

Yes, it's actually super fast. But the node.js startup time and loading all the required modules slows down formatting times. prettier_d reduces this overhead by running a server in the background. It brings the formatting time down from 0.25 seconds to 0.1 seconds on a 3265 byte file If you want to format from within your editor whenever you save a file, prettier_d is for you.

Install

This will install the prettier_d command globally:

yarn global add https://github.com/josephfrazier/prettier_d
# or
npm install -g https://github.com/josephfrazier/prettier_d

Usage

To start the server and format a file, just run:

prettier_d file.js

On the initial call, the prettier_d server is launched and then the given file is formatted. Subsequent invocations are super fast.

How does this work?

The first time you use prettier_d, a little server is started in the background and bound to a random port. The port number is stored along with a token in ~/.prettier_d. You can then run prettier_d commands the same way you would use prettier and it will delegate to the background server.

Commands

Control the server like this:

prettier_d <command>

Available commands:

  • start: start the server
  • stop: stop the server
  • status: print out whether the server is currently running
  • restart: restart the server
  • [options] file.js file.js: invoke prettier with the given options. The prettier engine will be created in the current directory. If the server is not yet running, it is started.

prettier_d will select a free port automatically and store the port number along with an access token in ~/.prettier_d.

Type prettier_d --help to see the supported prettier options.

Editor integration

See https://github.com/prettier/prettier#editor-integration

Real-time formatting in Vim

asciicast

If you use Vim, and you'd like prettier_d to format your code as you type, install Neoformat and add this to your ~/.vimrc:

autocmd FileType javascript setlocal formatprg=prettier_d\ --parser=babel
autocmd BufWritePre,TextChanged,InsertLeave *.js Neoformat

" Use formatprg when available
let g:neoformat_try_formatprg = 1
" https://github.com/sbdchd/neoformat/issues/25
let g:neoformat_only_msg_on_error = 1

Then, make sure you've started the server: prettier_d start.

This will format your code:

  • before each save
  • whenever text is changed in normal mode
  • whenever you leave insert mode

Prettier Banner

Opinionated Code Formatter

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML
Your favorite language?

Azure Pipelines Build Status Codecov Coverage Status Blazing Fast
npm version weekly downloads from npm code style: prettier Chat on Gitter Follow Prettier on Twitter

Intro

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

Input

foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());

Output

foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne()
);

Prettier can be run in your editor on-save, in a pre-commit hook, or in CI environments to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!


Documentation

Install · Options · CLI · API

Playground


Badge

Show the world you're using Prettiercode style: prettier

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Contributing

See CONTRIBUTING.md.

Project Statistics

Sourcerank 10
Repository Size 28 MB
Stars 75
Forks 4
Watchers 3
Open issues 2
Dependencies 0
Contributors 423
Tags 61
Created
Last updated
Last pushed

Top Contributors See all

Walter Breakell Christopher Chedeau Ika Lucas Duailibe Joseph Frazier Lucas Azzola James Long Simon Lydell Alexander Akait fisker Cheung Maximilian Antoni Brian Ng Lipis dependabot-preview[bot] Jed Fox Lily Skye SUZUKI Sosuke Davy Duperron Georgii Dolzhykov Danny Martini

Packages Referencing this Repo

prettier_d
Makes prettier the fastest formatter on the planet
This package is deprecated - Updated

Recent Tags See all

1.19.1 November 09, 2019
1.19.0 November 09, 2019
1.18.2 June 07, 2019
1.18.1 June 07, 2019
1.18.0 June 06, 2019
1.17.1 May 13, 2019
1.17.0 April 12, 2019
1.16.2 January 30, 2019
1.16.1 January 22, 2019
1.16.0 January 20, 2019
1.15.3 November 30, 2018
1.15.2 November 10, 2018
1.15.1 November 07, 2018
1.15.0 November 07, 2018
1.14.2 August 09, 2018

Something wrong with this page? Make a suggestion

Last synced: 2017-07-08 21:16:50 UTC

Login to resync this repository