Registry / devops / gulp-prettier-plugin

gulp-prettier-plugin

JSON →
library1.3.0jsnpmunverified

Gulp plugin (v1.3.0, last release 2019) to format source code with Prettier. Requires Prettier >=1.x as a peer dependency. Key differentiator: supports filter mode (only emit files needing formatting) and validate mode (fail CI if files unformatted). Alternative to gulp-prettier with more granular control. Ships TypeScript definitions. Minimalist API with two optional config objects (prettier options and plugin options).

npm install gulp-prettier-plugin
INSTALL
IMPORT
SIG · GULP-PRETTIER-PLUG
G
gulp-prettier-plugin
devopsjavascriptv1.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import prettierPlugin from 'gulp-prettier-plugin'
import * as prettierPlugin from 'gulp-prettier-plugin'
Default export is a function. TypeScript users can also use `import * as` but default import is recommended.
default (CJS)
const prettierPlugin = require('gulp-prettier-plugin')
const { prettierPlugin } = require('gulp-prettier-plugin')
The package exports a single function, not a named export.
IPrettierPluginOptions
import type { IPrettierPluginOptions } from 'gulp-prettier-plugin'
Type-only import for TypeScript users; no runtime symbol.

Gulp task that formats JS files in place, using filter to only rewrite files that need formatting.

const gulp = require('gulp'); const prettierPlugin = require('gulp-prettier-plugin'); gulp.task('prettier', () => gulp .src(['./src/**/*.js', './gulpfile.js']) .pipe(prettierPlugin({ singleQuote: true, trailingComma: 'all' }, { filter: true })) .pipe(gulp.dest(file => file.base)) );
Debug
Known issues
deprecatedPrettier v2+ has breaking changes; this plugin may not support all new options.
fix
Consider using gulp-prettier (v4+) or use prettier directly.
affects: >=1.3.0
gotchapluginOptions.filter does not work correctly when piping to other gulp plugins after formatting, as it only emits changed files.
fix
Set filter to false if you need to pipe output to other plugins (e.g., linter) for all files.
affects: >=0.0.0
gotchaMust call gulp.dest with a function returning file.base to write in-place, otherwise files go to cwd.
fix
Use `.pipe(gulp.dest(file => file.base))` instead of `.pipe(gulp.dest('./'))`.
affects: >=0.0.0
gotchaPrettier options are not validated; invalid options are silently ignored.
fix
Double-check Prettier option names and values.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: prettierPlugin is not a function
Using ES module import incorrectly (import * as).
fix
Use default import: import prettierPlugin from 'gulp-prettier-plugin' or const prettierPlugin = require('gulp-prettier-plugin').
Error: Cannot find module 'prettier'
Prettier not installed; it's a peer dependency.
fix
Run: npm install prettier --save-dev
gulp-dest: No files written
Forgetting to pass function to gulp.dest.
fix
Change .pipe(gulp.dest('./')) to .pipe(gulp.dest(file => file.base)).
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency; actual formatting engine
Agent activity
8 hits · last 30 days
node
8
Resources
gulp-prettier-plugin — npm install gulp-prettier-plugin · libregistry