gulp-prettier
Create vinyl streams to pipe to prettier
Last updated 4 months ago by thedancingcode .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-prettier 
SYNC missed versions from official npm registry.

Gulp Prettier Build Status

A Gulp plugin which allows the users to use Prettier.

Prettier is an opinionated JavaScript formatter inspired by refmt with advanced support for language features from ES2017, JSX, and Flow. It removes all original styling and ensures that all outputted JavaScript conforms to a consistent style. (See this blog post)

NOTE: To ensure this plugin continues to serve its usefulness, I've added @TheDancingCode as the active collaborator. He will be the active maintainer - BRP (April 26, 2018)

Install

npm install gulp-prettier --save-dev

Usage

Simply pipe the input, and pass in arguments that you would to the regular format function.

const gulp = require('gulp');
const prettier = require('gulp-prettier');

gulp.task('default', () => {
  return gulp.src('*.js')
    .pipe(prettier({ singleQuote: true }))
    .pipe(gulp.dest('./dist'));
});

To check whether or not your files adhere to Prettier's formatting, use prettier.check. This can be used as a validation step in CI scenarios.

const gulp = require('gulp');
const prettier = require('gulp-prettier');

gulp.task('validate', () => {
  return gulp.src('*.js')
    .pipe(prettier.check({ singleQuote: true }));
});

API

prettier([options])

Formats your files using Prettier.

options

Type: Object

Consult the Prettier options.

editorconfig: true can also be passed to enable EditorConfig support.

prettier.check([options])

Checks if your files have been formatted with Prettier and, if not, throws an error with a list of unformatted files. This is useful for running Prettier in CI scenarios.

options

Type: Object

Consult the Prettier options.

editorconfig: true can also be passed to enable EditorConfig support.

Collaborators

I'd like to take this oppertunity to thank all of the contributors to this project:

- @akella - @trusktr - @TheDancingCode

License

MIT License

Current Tags

  • 3.0.0                                ...           latest (4 months ago)

7 Versions

  • 3.0.0                                ...           4 months ago
  • 2.3.0                                ...           8 months ago
  • 2.2.0                                ...           9 months ago
  • 2.1.0                                ...           a year ago
  • 2.0.0                                ...           2 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago

Copyright 2014 - 2017 © taobao.org |