├── .gitignore ├── .npmignore ├── .eslintrc ├── config_parser.js ├── test └── config_parser.spec.js ├── README.md ├── package.json ├── LICENSE └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .idea 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .eslintrc 3 | test/*.spec.js -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "emarsys" 5 | ], 6 | "env": { 7 | "node": true, 8 | "es6": true 9 | }, 10 | "rules": { 11 | "no-unused-vars": [ 12 | 2, { 13 | "vars": "all", 14 | "args": "after-used" 15 | } 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /config_parser.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _ = require('lodash'); 4 | var path = require('path'); 5 | var util = require('util'); 6 | 7 | module.exports = function configParser(config) { 8 | if (config.extends) { 9 | var configPath = path.resolve(util.format('node_modules/pug-lint-config-%s', config.extends), 'index.js'); 10 | 11 | try { 12 | var defaultConfig = require(configPath); 13 | return _.extend({}, defaultConfig, _.omit(config, 'extends')); 14 | } catch (e) { 15 | // no prob 16 | } 17 | } 18 | 19 | return config; 20 | }; 21 | -------------------------------------------------------------------------------- /test/config_parser.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var emarsysConfig = require('pug-lint-config-emarsys'); 4 | var expect = require('chai').expect; 5 | var configParser = require('../config_parser'); 6 | 7 | describe('configParser', function() { 8 | it('should return original config without extends', function() { 9 | var config = configParser({extends: 'emarsys', validateIndentation: 4}); 10 | 11 | expect(config.extends).to.be.undefined; 12 | expect(config.validateIndentation).to.eql(4); 13 | }); 14 | 15 | it('should extend with given config', function() { 16 | var config = configParser({extends: 'emarsys', additionalField: 4}); 17 | 18 | expect(config).to.contain(emarsysConfig); 19 | }) 20 | }); 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gulp plugin for pug-lint 2 | 3 | [![npm version](https://badge.fury.io/js/gulp-pug-lint.svg)](http://badge.fury.io/js/gulp-pug-lint) 4 | [![Dependency Status](https://david-dm.org/emartech/gulp-pug-lint.svg)](https://david-dm.org/emartech/gulp-pug-lint) 5 | [![devDependency Status](https://david-dm.org/emartech/gulp-pug-lint/dev-status.svg)](https://david-dm.org/emartech/gulp-pug-lint#info=devDependencies) 6 | 7 | ## Usage 8 | 9 | ```javascript 10 | var gulp = require('gulp'), 11 | puglint = require('gulp-pug-lint'); 12 | 13 | gulp.task('default', function () { 14 | return gulp 15 | .src('views/*.jade') 16 | .pipe(puglint()); 17 | }); 18 | ``` 19 | 20 | ## Configuration 21 | 22 | Plugin will read [.pug-lintrc file](https://github.com/pugjs/pug-lint#configuration-file). 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-pug-lint", 3 | "version": "0.1.6", 4 | "description": "Gulp plugin for pug-lint", 5 | "homepage": "https://github.com/emartech/gulp-pug-lint", 6 | "repository": "git://github.com/emartech/gulp-pug-lint.git", 7 | "main": "index.js", 8 | "scripts": { 9 | "test": "mocha test/*.spec.js && eslint *.js" 10 | }, 11 | "keywords": [ 12 | "gulp", 13 | "plugin", 14 | "pug", 15 | "lint" 16 | ], 17 | "author": "Emarsys", 18 | "license": "MIT", 19 | "dependencies": { 20 | "gulp-util": "3.0.7", 21 | "pug-lint": "2.1.2", 22 | "lodash": "3.10.1", 23 | "rcloader": "0.1.4", 24 | "through2": "2.0.0" 25 | }, 26 | "devDependencies": { 27 | "chai": "3.4.1", 28 | "eslint": "1.10.3", 29 | "eslint-config-emarsys": "1.0.0", 30 | "pug-lint-config-emarsys": "2.0.0", 31 | "mocha": "2.3.4" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Emarsys Technologies Ltd. 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var gutil = require('gulp-util'); 4 | var through = require('through2'); 5 | var PugLint = require('pug-lint'); 6 | var RcLoader = require('rcloader'); 7 | var configParser = require('./config_parser'); 8 | 9 | module.exports = function(options) { 10 | var rc = new RcLoader('.pug-lintrc', options); 11 | 12 | return through.obj(function(file, enc, cb) { 13 | if (file.isNull()) { 14 | return cb(null, file); 15 | } 16 | 17 | if (file.isStream()) { 18 | return cb(new gutil.PluginError('gulp-pug-lint', 'streaming not supported')); 19 | } 20 | 21 | rc.for(file.path, function(errRc, conf) { 22 | if (errRc) { 23 | return cb(new gutil.PluginError('gulp-pug-lint', errRc)); 24 | } 25 | 26 | try { 27 | var linter = new PugLint(); 28 | linter.configure(configParser(conf)); 29 | 30 | var errors = linter.checkFile(file.path); 31 | 32 | if (errors.length) { 33 | gutil.log(gutil.colors.cyan(errors.length) + ' issues found in ' + gutil.colors.magenta(file.path)); 34 | errors.forEach(function(error) { 35 | gutil.log(error.message); 36 | }); 37 | } 38 | } catch (errLint) { 39 | return cb(new gutil.PluginError('gulp-pug-lint', errLint)); 40 | } 41 | 42 | cb(null, file); 43 | }); 44 | 45 | }); 46 | 47 | }; 48 | --------------------------------------------------------------------------------