{"id":16739303,"url":"https://github.com/olehdutchenko/gulp-happiness","last_synced_at":"2025-07-11T02:33:37.934Z","repository":{"id":57257697,"uuid":"91383292","full_name":"OlehDutchenko/gulp-happiness","owner":"OlehDutchenko","description":"Gulp plugin for happiness","archived":false,"fork":false,"pushed_at":"2017-11-18T07:31:06.000Z","size":147,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-31T07:07:32.748Z","etag":null,"topics":["code-style","gulp-plugin","happiness","javascript","linter"],"latest_commit_sha":null,"homepage":"","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/OlehDutchenko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-15T20:46:45.000Z","updated_at":"2017-05-27T19:13:17.000Z","dependencies_parsed_at":"2022-08-25T19:12:37.753Z","dependency_job_id":null,"html_url":"https://github.com/OlehDutchenko/gulp-happiness","commit_stats":null,"previous_names":["dutchenkooleg/gulp-happiness"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/OlehDutchenko/gulp-happiness","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-happiness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-happiness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-happiness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-happiness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OlehDutchenko","download_url":"https://codeload.github.com/OlehDutchenko/gulp-happiness/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-happiness/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264713020,"owners_count":23652703,"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":["code-style","gulp-plugin","happiness","javascript","linter"],"created_at":"2024-10-13T00:50:07.109Z","updated_at":"2025-07-11T02:33:37.676Z","avatar_url":"https://github.com/OlehDutchenko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-happiness\n\n![npm](https://img.shields.io/badge/node-6.3.1-yellow.svg)\n[![es2015](https://img.shields.io/badge/ECMAScript-2015_(ES6)-blue.svg)](https://nodejs.org/en/docs/es6/) \n[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/dutchenkoOleg/gulp-happiness/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/dutchenkoOleg/gulp-happiness.svg?branch=master)](https://travis-ci.org/dutchenkoOleg/gulp-happiness)\n[![Dependencies](https://www.versioneye.com/user/projects/592bb907a8a056006137f481/badge.svg?style=flat)](https://www.versioneye.com/user/projects/592bb907a8a056006137f481?child=summary)\n\n\u003e _Gulp plugin for [happiness](https://www.npmjs.com/package/happiness)_\n\n[![js-happiness-style](https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg)](https://github.com/JedWatson/happiness)\n\n---\n\n## Installing\n\n```shell\nnpm install --save gulp-happiness\n# or using yarn cli\nyarn add gulp-happiness\n```\n\n## Usage\n\nCheck out files with [happiness](https://www.npmjs.com/package/happiness) linter\n\n```js\nconst gulp = require('gulp');\nconst gulpHappiness = require('gulp-happiness');\n\ngulp.task('lint', function () {\n\treturn gulp.src(['**/*.js','!node_modules/**'])\n\t\t// Attaches the lint data to the \"eslint\" property\n\t\t// of the file object so it can be used by other modules. \n\t\t// By default it will skip files with empty content\n\t\t// and if filename starts with _ (underscore)\n\t\t.pipe(gulpHappiness())\n\t\t\n\t\t// eslint.format() outputs the lint results to the console.\n\t\t.pipe(gulpHappiness.format())\n\t\t\n\t\t// Look after checking all the streamed files,\n\t\t// and if at least one of them has errors it will fail.\n\t\t// Note! This method does not transfer files further to the stream!\n\t\t.pipe(gulpHappiness.failAfterError());\n});\n```\n\nLint files, fix and transfer\n\n```js\nconst gulp = require('gulp');\nconst gulpHappiness = require('gulp-happiness');\n\ngulp.task('lint', function () {\n\treturn gulp.src('./src/scripts/**/*.js')\n\t\t// Enable fixing - fix: true.\n\t\t// If auto fixing cannot be done, \n\t\t// you will see message in console about it\n\t\t.pipe(gulpHappiness({\n\t\t\tfix: true\n\t\t}))\n\t\t\n\t\t// Show in console happy files ;)\n\t\t.pipe(gulpHappiness.format({\n\t\t\tshowHappyFiles: true\n\t\t}))\n\t\t\n\t\t// Failing if file has eslint errors,\n\t\t// it will break task immediately.\n\t\t// Current file and all next not will be transferred\n\t\t.pipe(gulpHappiness.failOnError())\n\t\t\n\t\t// transfer files\n\t\t.pipe(gulp.dest('./dist/assets/js/'));\n});\n```\n\n---\n\n## API\n\n- [gulpHappiness()](#gulphappiness)\n- [gulpHappiness(options)](#gulphappinessoptions)\n\n\n\n- [gulpHappiness.format()](#gulphappinessformat)\n- [gulpHappiness.format(formatterName)](#gulphappinessformatformattername)\n- [gulpHappiness.format(formatterFunction)](#gulphappinessformatformatterfunction)\n- [gulpHappiness.format(formatterName/formatterFunction, options)](#gulphappinessformatformatternameformatterfunction-options)\n\n\n\n- [gulpHappiness.failOnError()](#gulphappinessfailonerror)\n- [gulpHappiness.failOnError(options)](#gulphappinessfailonerroroptions)\n\n\n\n- [gulpHappiness.failAfterError()](#gulphappinessfailaftererror)\n- [gulpHappiness.failAfterError(options)](#gulphappinessfailaftererroroptions)\n\n### gulpHappiness()\n\n_No explicit configuration._   \nLinting with default options.  \nAttaches the lint data to the \"eslint\" property of the file object so it can be used by other modules. \n\n### gulpHappiness(options)\n\n#### options.fix\n\ntype `boolean` /\ndefault `undefined`  \nFix most issues automatically if set `true`.\n\n*__Note!__ It will not fix original files in your fs.  \nIt will fix files in stream and you must save them where you need by using `gulp.dest()`  after linting*\n\n*__Note!__ If auto fixing cannot be done - you will see message in console about it.*  \n_Example of log:_\n\n![Cannot auto fix example](https://raw.githubusercontent.com/dutchenkoOleg/gulp-happiness/master/assets/connot-auto-fix.png)\n\n#### options.linterOptions\n\ntype `Object` /\ndefault `undefined`  \nOptions for [happiness](https://www.npmjs.com/package/happiness) linter\n\n#### options.linterOptions.globals  \n\ntype `Array.\u003cstring\u003e` /\ndefault `undefined`  \nCustom global variables to declare (e.g. `['jquery', '$']`)\n\n#### options.linterOptions.plugins  \n\ntype `Array.\u003cstring\u003e` /\ndefault `undefined`  \nCustom eslint plugins\n\n#### options.linterOptions.envs  \n\ntype `Array.\u003cstring\u003e` /\ndefault `undefined`  \nCustom eslint environment\n\n#### options.linterOptions.parser  \n\ntype `string` /\ndefault `undefined`  \nCustom js parser (e.g. `'babel-eslint'`)\n\n#### options.noUnderscore\n\ntype `boolean` /\ndefault `true`  \nFile which name starts with _ (underscore) will be skipped and not using in stream next.  \n\n_You will receive message in console if it happens._  \n_Example of log:_\n\n![no-empty log example](https://raw.githubusercontent.com/dutchenkoOleg/gulp-not-supported-file/master/assets/no-underscore.png)\n\n\n#### options.noEmpty\n\ntype `boolean` /\ndefault `true`  \nFile with empty content will be skipped and not using in stream next.  \n_**Note!** Spaces, tabs and newlines will be treated as empty content._  \n\n_You will receive message in console if it happens._  \n_Example of log:_\n\n![no-empty log example](https://raw.githubusercontent.com/dutchenkoOleg/gulp-not-supported-file/master/assets/no-empty.png)\n\n\n#### options.silent\n\ntype `boolean` /\ndefault `undefined`  \nNo logs about `noEmpty` and `noUnderscore` files\n\n### gulpHappiness.format()\n\n_No explicit configuration._   \nOutputs the lint results to the console.  \nDefault formatter is [`eslint-formatter-pretty`](https://www.npmjs.com/package/eslint-formatter-pretty)\n\n### gulpHappiness.format(formatterName)\n\n#### formatterName\n\ntype `string`  \nYou can use formatter by default  \n`gulpHappiness.format('default')` - same as `gulpHappiness.format()`  \n\nor use one of the [ESLint-provided formatters](https://github.com/eslint/eslint/tree/master/lib/formatters),  \nfor example `gulpHappiness.format('stylish')` \n\nor use some else formatter which you can install from npm [https://www.npmjs.com/search?q=eslint+formatter](https://www.npmjs.com/search?q=eslint+formatter)  \n_Example_\n\n```shell\nnpm i --save eslint-friendly-formatter\n```\n\n```js\nconst gulp = require('gulp');\nconst gulpHappiness = require('gulp-happiness');\n\ngulp.task('lint', function () {\n\treturn gulp.src(['**/*.js','!node_modules/**'])\n\t\t.pipe(gulpHappiness())\n\t\t.pipe(gulpHappiness.format('eslint-friendly-formatter'))\n});\n```\n\n### gulpHappiness.format(formatterFunction)\n\n#### formatterFunction(results[, formatterOptions])\n\ntype `function`\n\n_Parameters:_\n\nName | Data type | Description\n --- | --- | ---\n `results` | `Array` | Results of eslint\n `formatterOptions` | `Object/undefined` | Options for formatter\n\t\nYou can use own function or existing formatters as function [https://www.npmjs.com/search?q=eslint+formatter](https://www.npmjs.com/search?q=eslint+formatter)\n\n___Note!___ Function will receive results array from  eslint data for formatting.   \nAnd it is must return output as string if has problems in received results for console or some negative value, e.g. `null | undefined | false | '' `.\n\n_Example with custom formatter function_\n\n```js\nconst gulp = require('gulp');\nconst gulpHappiness = require('gulp-happiness');\n\ngulp.task('lint', function () {\n\treturn gulp.src(['**/*.js','!node_modules/**'])\n\t\t.pipe(gulpHappiness())\n\t\t.pipe(gulpHappiness.format(function(results, formatterOptions={}) {\n\t\t\t// process results and options\n\t\t\t// ...\n\t\t\t\n\t\t\tlet output = myOwnMethodForTransformResults(results, transformOptions);\n\t\t\t\n\t\t\treturn output;\n\t\t}))\n});\n```\n\n_Example with installed formatter function_\n\n```shell\nnpm i --save eslint-friendly-formatter\n```\n\n```js\nconst gulp = require('gulp');\nconst gulpHappiness = require('gulp-happiness');\nconst eslintFriendlyFormatter = require('eslint-friendly-formatter');\n\ngulp.task('lint', function () {\n\treturn gulp.src(['**/*.js','!node_modules/**'])\n\t\t.pipe(gulpHappiness())\n\t\t.pipe(gulpHappiness.format(eslintFriendlyFormatter))\n});\n```\n\n### gulpHappiness.format(formatterName/formatterFunction, options)\n\n#### formatterName/formatterFunction\n\nsee above [formatterName](#formattername) and [formatterFunction](#formatterfunctionresults-formatteroptions)\n\n\n#### options.formatterOptions\n\ntype `Object` /\ndefault `undefined`  \nOptions for the chosen formatter \n\n#### options.showHappyFiles\n\ntype `boolean` /\ndefault `undefined`  \nShow files without problems in console\n\n_Example of log:_\n\n![Show happy files example](https://raw.githubusercontent.com/dutchenkoOleg/gulp-happiness/master/assets/show-hapy-files.png)\n\n#### options.noUnderscore\n\nSame as [gulpHappiness(options) → options.noUnderscore](#optionsnounderscore)\n\n#### options.noEmpty\n\nSame as [gulpHappiness(options) → options.noEmpty](#optionsnoempty)\n\n#### options.silent\n\nSame as [gulpHappiness(options) → options.silent](#optionssilent)\n\n\n### gulpHappiness.failOnError()\n\n_No explicit configuration._ \n\n### gulpHappiness.failOnError(options)\n\n#### options.disabled\n\ntype `boolean` /\ndefault `undefined`  \nNot fail on errors \n\n#### options.onEnd(errorMsg, eslintData)\n\ntype `fucnction` /\ndefault `undefined`  \n\n_Parameters:_\n\nName | Data type | Description\n --- | --- | ---\n `errorMsg` | `null/string` | Is `null` if no errors were found and is `string` if errors were found. String contains a short message about errors\n `eslintData` | `Object` | eslint data from file\n \nIts call will be before ending of pipe. So you don't need apply no callbacks or return some values.  \nYou can use it for own custom actions, e.g rewrite some globals.  \n___Note!___ Even if `options.disabled` - is `true` - this function will be called\n\n\n#### options.noUnderscore\n\nSame as [gulpHappiness(options) → options.noUnderscore](#optionsnounderscore)\n\n#### options.noEmpty\n\nSame as [gulpHappiness(options) → options.noEmpty](#optionsnoempty)\n\n#### options.silent\n\nSame as [gulpHappiness(options) → options.silent](#optionssilent)\n\n\n### gulpHappiness.failAfterError()\n\n_No explicit configuration._ \n\n### gulpHappiness.failAfterError(options)\n\n#### options.disabled\n\nSame as [gulpHappiness.failOnError(options) → options.disabled](#optionsdisabled)\n\n#### options.onEnd(errorMsg, errorFilesPaths, allErrorsCount)\n\ntype `fucnction` /\ndefault `undefined`  \n\n_Parameters:_\n\nName | Data type | Description\n --- | --- | ---\n `errorMsg` | `null/string` | Is `null` if no errors were found and is `string` if errors were found. String contains a short message about errors\n `errorFilesPaths` | `Array` | Array of files with errors. It will an empty if no files.\n `allErrorsCount` | `number` | Count of all errors. Will be 0 if no errors\n \nIts call will be before ending of pipe. So you don't need apply no callbacks or return some values.  \nYou can use it for own custom actions, e.g rewrite some globals.  \n___Note!___ Even if `options.disabled` - is `true` - this function will be called\n\n#### options.noUnderscore\n\nSame as [gulpHappiness(options) → options.noUnderscore](#optionsnounderscore)\n\n#### options.noEmpty\n\nSame as [gulpHappiness(options) → options.noEmpty](#optionsnoempty)\n\n#### options.silent\n\nSame as [gulpHappiness(options) → options.silent](#optionssilent)\n\n## Tests\n\n1. `npm test` for testing code style and run mocha tests\n1. `npm run happiness-fix` for automatically fix most of problems with code style \n\n## Changelog\n\nPlease read [CHANGELOG.md](https://github.com/dutchenkoOleg/gulp-happiness/blob/master/CHANGELOG.md)\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/dutchenkoOleg/gulp-happiness/blob/master/CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdutchenko%2Fgulp-happiness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folehdutchenko%2Fgulp-happiness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdutchenko%2Fgulp-happiness/lists"}