Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gulp-prettier

thomasvantuycom111.1kMIT6.0.0

Format files with Prettier

gulp, prettier, gulp-prettier, gulpplugin

readme

gulp-prettier

Format files with Prettier

GitHub Workflow Status npm version semantic-release

Install

npm install gulp-prettier --save-dev

Usage

import gulp from 'gulp';
import prettier from 'gulp-prettier';

function format() {
  return gulp.src('src/*.js')
    .pipe(prettier({ singleQuote: true }))
    .pipe(gulp.dest('dist'));
}

export default format;

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.

import gulp from 'gulp';
import prettier from 'gulp-prettier';

function validate() {
  return gulp.src('dist/*.js')
    .pipe(prettier.check({ singleQuote: true }));
}

export default validate;

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.

License

MIT © Thomas Vantuycom

changelog

6.0.0 (2023-11-03)

Code Refactoring

  • move to ESM and require Node 18 (29268a0)

BREAKING CHANGES

  • The plugin is now pure ESM
  • Requires Node 18

5.0.0 (2023-07-05)

Build System

  • drop Node 12 and 14 support (0c15e92)

Features

  • upgrade Prettier to 3.0.0 (f0e4174)

BREAKING CHANGES

  • dropped Node 12 and 14 support.

4.0.0 (2021-07-31)

Build System

BREAKING CHANGES

  • dropped Node 10 support.

Changelog

3.0.0 (2019-03-21)

Features

  • upgrade Prettier to v2.0.0 (af1a07c)

BREAKING CHANGES

2.3.0 (2019-11-11)

Features

  • show filename on formatting error (565f3d3)

2.2.0 (2019-10-21)

Features

2.1.0 (2019-02-01)

Bug Fixes

  • upgrade through2 to v3.0.0 (7b16a27)

Features

  • add check method for CI (5f67343)

2.0.0 (2018-05-01)

Bug Fixes

  • avoid deprecated new Buffer() (d007ff9)
  • correct undeclared variable (c9abbbe)
  • use strict mode (cf7bec7)

Features

  • add support for languages other than js (2eb0ed9)
  • adhere to .prettierrc (d44a6b0)
  • add isPrettier flag (7d790fd)

BREAKING CHANGES

  • Upgrade Prettier to ^1.5.3 (7d790fd)

1.1.0 (2017-01-16)

Bug fixes

1.0.0 (2017-01-15)

Initial release