# using npmnpm install --save-dev gulp-plugin-prettier gulp prettier# using yarnyarn add --dev gulp-plugin-prettier gulp prettier
NOTE: For TypeScript user, you have to install @types/prettier to get full types.
Usage
(gulpfile.ts)
import * as gulp from 'gulp';import * as prettier from 'gulp-plugin-prettier';// replace unformatted with formattedfunction format() { return gulp.src(['./src/**/*.ts', './gulpfile.ts']) .pipe(prettier.format({ singleQuote: true })) .pipe(gulp.dest(file => file.base));}// throw error if there is unformatted filefunction format_check() { return gulp.src(['./src/**/*.ts', './gulpfile.ts']) .pipe
(gulpfile.js)
const gulp = require('gulp');const prettier = require('gulp-plugin-prettier');// replace unformatted with formattedfunction format() { return gulp.src(['./src/**/*.js', './gulpfile.js']) .pipe(prettier.format({ singleQuote: true })) .pipe(gulp.dest(file => file.base));}// throw error if there is unformatted filefunction format_check() { return gulp.src(['./src/**/*.js', './gulpfile.js']) .pipe