{"id":20947204,"url":"https://github.com/gaumala/gulp-prettier-plugin","last_synced_at":"2025-05-14T01:32:07.129Z","repository":{"id":57258574,"uuid":"96734727","full_name":"GAumala/gulp-prettier-plugin","owner":"GAumala","description":"gulp plugin for prettier","archived":false,"fork":false,"pushed_at":"2018-04-01T23:52:10.000Z","size":55,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T15:15:02.101Z","etag":null,"topics":["gulp-plugins","prettier","typescript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GAumala.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-10T04:08:50.000Z","updated_at":"2019-06-28T16:49:20.000Z","dependencies_parsed_at":"2022-08-28T21:41:50.549Z","dependency_job_id":null,"html_url":"https://github.com/GAumala/gulp-prettier-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GAumala%2Fgulp-prettier-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GAumala%2Fgulp-prettier-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GAumala%2Fgulp-prettier-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GAumala%2Fgulp-prettier-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GAumala","download_url":"https://codeload.github.com/GAumala/gulp-prettier-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225270659,"owners_count":17447635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp-plugins","prettier","typescript"],"created_at":"2024-11-19T00:09:55.170Z","updated_at":"2024-11-19T00:09:55.960Z","avatar_url":"https://github.com/GAumala.png","language":"JavaScript","readme":"# gulp-prettier-plugin\n\n[![Build Status](https://travis-ci.org/GAumala/gulp-prettier-plugin.svg?branch=master)](https://travis-ci.org/GAumala/gulp-prettier-plugin) [![Coverage Status](https://coveralls.io/repos/github/GAumala/gulp-prettier-plugin/badge.svg?branch=master)](https://coveralls.io/github/GAumala/gulp-prettier-plugin?branch=master) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\ngulp plugin to format your source code files with [prettier](https://github.com/prettier/prettier).\n\n## Install\n\n```\nyarn add --dev gulp-prettier-plugin\n```\n\n`prettier` is marked as a peer dependency, so if you already have it installed, the plugin will use that version.\n\n## Usage\n\nThis module exports a single function with this signature:\n\n```TypeScript\ndeclare const prettierPlugin: (prettierOptions: any, pluginOptions: IPrettierPluginOptions) =\u003e PrettierTransform;\n```\n\nThe function receives 2 optional arguments: `prettierOptions`, the options object [to configure prettier](https://github.com/prettier/prettier#options), and `pluginOptions`, options to configure the plugin. The return object is a Transform stream, just like most gulp plugins. The supported plugin options are the following:\n\nName | Type | Description\n--- | --- | ---\n`filter` | `boolean` | If `true`, the plugin will only emit files that need formatting.  This is useful when you are piping to `gulp.dest` and only want to write the files that haven't been formatted yet, otherwise every single file will be rewritten.\n`validate` | `boolean` | If `true`, after all files are processed, it will throw an error if any input files were not already formatted, detailing the paths of each. You might want to turn this on only in continuous integration environments to make sure all files are formatted before any patches are merged to your repository.\n\nAll options are false by default.\n\n## Examples\n\nFormat in-place only JS files that haven't been already formatted:\n\n``` javascript\nconst gulp = require('gulp');\nconst prettierPlugin = require('gulp-prettier-plugin');\n\ngulp.task('prettier', () =\u003e\n  gulp\n    .src(['./src/**/*.js', './gulpfile.js'])\n    .pipe(prettierPlugin(undefined, { filter: true }))\n    // passing a function that returns base will write the files in-place\n    .pipe(gulp.dest(file =\u003e file.base))\n);\n```\n\nFormat in-place all TypeScript and LESS files that haven't already been formatted:\n\n``` javascript\ngulp.task(\"prettier\", () =\u003e\n  gulp\n    .src([\"./src/**/*.ts\", \"./src/**/*.less\"])\n    .pipe(prettierPlugin(undefined, { filter: true }))\n    // passing a function that returns base will write the files in-place\n    .pipe(gulp.dest(file =\u003e file.base))\n);\n```\nSame as the previous example, but written in TypeScript\n\n``` typescript\nimport * as gulp from 'gulp'\nimport * as prettierPlugin from 'gulp-prettier-plugin'\n\ngulp.task('prettier', () =\u003e\n  gulp\n    .src(['./src/**/*.ts', './src/**/*.less'])\n    .pipe(prettierPlugin(undefined, { filter: true })\n    )\n    // passing a function that returns base will write the files in-place\n    .pipe(gulp.dest(file =\u003e file.base))\n);\n```\n\nFormat each and every JS file in place, using the [trailing-comma](https://github.com/prettier/prettier#trailing-commas) and [single-quote](https://github.com/prettier/prettier#quotes) options, and pipe any other plugin such as [eslint](eslint.org) before writing:\n\n``` javascript\nconst gulp = require('gulp');\nconst prettierPlugin = require('gulp-prettier-plugin');\nconst eslint = require('gulp-eslint');\n\ngulp.task('prettier', () =\u003e\n  gulp\n    .src(['./src/**/*.js', './gulpfile.js'])\n    .pipe(prettierPlugin())\n    .pipe(eslint())\n    .pipe(eslint.failAfterError())\n    // passing a function that returns base will write the files in-place\n    .pipe(gulp.dest(file =\u003e file.base))\n);\n```\n\nScan al JS files and when it finds a file that hasn't been formatted yet, format it in-place and save the path so that if it is running in a CI environment, it throws an error detailing the files that were not already formatted.\n\n``` javascript\nconst gulp = require('gulp');\nconst prettierPlugin = require('gulp-prettier-plugin');\nconst isCI = process.env.CI;\n\ngulp.task('prettier', () =\u003e\n  gulp\n    .src(['./src/**/*.js', './gulpfile.js'])\n    .pipe(\n      prettierPlugin(\n        {\n          trailingComma: 'es5',\n          singleQuote: true,\n        },\n        {\n          filter: true,\n          validate: isCI,\n        }\n      )\n    )\n    // passing a function that returns base will write the files in-place\n    .pipe(gulp.dest(file =\u003e file.base))\n);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaumala%2Fgulp-prettier-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaumala%2Fgulp-prettier-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaumala%2Fgulp-prettier-plugin/lists"}