![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
gulp-plugin-prettier
Advanced tools
Gulp plugin to format code with Prettier
# using npm
npm install --save-dev gulp-plugin-prettier gulp prettier
# using yarn
yarn add --dev gulp-plugin-prettier gulp prettier
NOTE: For TypeScript user, you have to install @types/prettier
to get full types.
(gulpfile.ts)
import * as gulp from 'gulp';
import * as prettier from 'gulp-plugin-prettier';
// replace unformatted with formatted
function 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 file
function format_check() {
return gulp.src(['./src/**/*.ts', './gulpfile.ts'])
.pipe(
prettier.format({ singleQuote: true }, { reporter: prettier.Reporter.Error }),
);
}
(gulpfile.js)
const gulp = require('gulp');
const prettier = require('gulp-plugin-prettier');
// replace unformatted with formatted
function 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 file
function format_check() {
return gulp.src(['./src/**/*.js', './gulpfile.js'])
.pipe(prettier.format({ singleQuote: true }, { reporter: 'error' }));
}
export function format(prettier_options?: PrettierOptions, plugin_options?: PluginOptions): stream.Transform;
export interface PluginOptions {
/**
* default: 'warning'
* report the filenames of files that are different from Prettier formatting
*/
reporter?: Reporter | CustomReporter;
/**
* default: false
* omit formatted files
*/
filter?: boolean;
/**
* default: true
* include rules from Prettier config files, e.g. .prettierrc
*/
configFile?: boolean;
}
export const enum Reporter {
/**
* do nothing
*/
None = 'none',
/**
* throw error for the filenames of files that are different from Prettier formatting
*/
Error = 'error',
/**
* print warning for the filenames of files that are different from Prettier formatting
*/
Warning = 'warning'
}
export type CustomReporter = (filename: string, different: boolean) => void;
# lint
yarn run lint
# format
yarn run format
# build
yarn run build
# test
yarn run test
MIT © Ika
FAQs
Gulp plugin to format code with Prettier
We found that gulp-plugin-prettier demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.