├── .gitattributes ├── .gitignore ├── LICENSE.md ├── README.md ├── index.js ├── package.json ├── screenshot.png └── screenshot2.png /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2015 Christoph Werner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gulp-jscs-stylish 2 | 3 | > This repository and package is **no longer maintained**. 4 | > If you're interested in changes, updates or security fixes, please create a fork! 5 | 6 | [![NPM Version](https://img.shields.io/npm/v/gulp-jscs-stylish.svg?style=flat&label=NPM%20Version)](http://npm.im/gulp-jscs-stylish) 7 | [![Build Status](https://img.shields.io/npm/dm/gulp-jscs-stylish.svg?style=flat)](http://npm.im/gulp-jscs-stylish) 8 | [![MIT License](https://img.shields.io/npm/l/gulp-jscs-stylish.svg?style=flat&label=License)](http://opensource.org/licenses/MIT) 9 | 10 | Stylish reporter for [gulp-jscs](https://github.com/jscs-dev/gulp-jscs), uses [jshint-stylish](https://github.com/sindresorhus/jshint-stylish) to do the actual reporting: 11 | 12 | ![screenshot](screenshot.png) 13 | 14 | Compared to the default output: 15 | 16 | ![screenshot](screenshot2.png) 17 | 18 | ## Install 19 | 20 | ```sh 21 | $ npm i --save-dev gulp-jscs-stylish 22 | ``` 23 | 24 | 25 | ## Usage 26 | 27 | ```js 28 | var jscs = require('gulp-jscs'); 29 | var noop = function () {}; 30 | var stylish = require('gulp-jscs-stylish'); 31 | 32 | gulp.task('default', function () { 33 | gulp.src([ 'file.js' ]) 34 | .pipe(jscs()) // enforce style guide 35 | .pipe(stylish()); // log style errors 36 | }); 37 | ``` 38 | 39 | 40 | ## Combine results with those of JSHint 41 | 42 | ```js 43 | var jscs = require('gulp-jscs'); 44 | var jshint = require('gulp-jshint'); 45 | var noop = function () {}; 46 | var stylish = require('gulp-jscs-stylish'); 47 | 48 | gulp.task('default', function () { 49 | gulp.src([ 'file.js' ]) 50 | .pipe(jshint()) // hint (optional) 51 | .pipe(jscs()) // enforce style guide 52 | .pipe(stylish.combineWithHintResults()) // combine with jshint results 53 | .pipe(jshint.reporter('jshint-stylish')); // use any jshint reporter to log hint 54 | // and style guide errors 55 | }); 56 | ```` 57 | using `.pipe(jshint())` is optional. you may very well use the reporter without running jshint 58 | 59 | ## License 60 | 61 | MIT © [Christoph Werner](http://twitter.com/gonsfx) 62 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var tap = require('gulp-tap'); 3 | var stylish = typeof require('jshint-stylish') === 'string' ? require(require('jshint-stylish')) : require('jshint-stylish'); 4 | 5 | function byErrorLine (a, b) { 6 | return a.error.line - b.error.line; 7 | } 8 | 9 | function tapJscs (action) { 10 | return function () { 11 | return tap(function (file) { 12 | if (!file.jscs || file.jscs.success) { 13 | return; 14 | } 15 | action(file); 16 | }); 17 | }; 18 | } 19 | 20 | function toJshint (file) { 21 | // fetch error list 22 | var errorList = file.jscs.errors._errorList || file.jscs.errors; 23 | var filePath = path.relative(process.cwd(), file.path); 24 | 25 | // map errors to jshint format 26 | return errorList.map(function (error) { 27 | return { 28 | file: filePath, 29 | error: { 30 | character: error.column, 31 | code: 'W ' + error.rule, 32 | line: error.line, 33 | reason: error.message 34 | } 35 | } 36 | }); 37 | } 38 | 39 | module.exports = tapJscs(function (file) { 40 | stylish.reporter(toJshint(file)); 41 | }); 42 | 43 | module.exports.combineWithHintResults = tapJscs(function (file) { 44 | file.jshint = file.jshint || {}; 45 | file.jshint.success = false; 46 | file.jshint.results = (file.jshint.results || []).concat(toJshint(file)); 47 | file.jshint.results.sort(byErrorLine); 48 | }); 49 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-jscs-stylish", 3 | "version": "1.4.0", 4 | "description": "Stylish reporter for gulp-jscs", 5 | "license": "MIT", 6 | "repository": "codepunkt/gulp-jscs-stylish", 7 | "author": "Christoph Werner ", 8 | "engines": { 9 | "node": ">=0.10.0" 10 | }, 11 | "scripts": { 12 | "test": "mocha" 13 | }, 14 | "files": [ 15 | "index.js" 16 | ], 17 | "keywords": [ 18 | "gulpplugin", 19 | "jscs", 20 | "reporter", 21 | "code style", 22 | "formatter", 23 | "lint", 24 | "linter", 25 | "style guide", 26 | "validate", 27 | "stylish", 28 | "elegant" 29 | ], 30 | "dependencies": { 31 | "gulp-tap": "^0.1.3", 32 | "jshint-stylish": "^2.0.0" 33 | }, 34 | "devDependencies": { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepunkt/gulp-jscs-stylish/fbbcc3605818c2e58dca34b9aa0910e97b90e695/screenshot.png -------------------------------------------------------------------------------- /screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepunkt/gulp-jscs-stylish/fbbcc3605818c2e58dca34b9aa0910e97b90e695/screenshot2.png --------------------------------------------------------------------------------