Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-lintspaces

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-lintspaces - npm Package Compare versions

Comparing version 0.3.4 to 0.4.0

78

index.js
var
es = require('event-stream'),
Lintspaces = require('lintspaces'),
PluginError = require('gulp-util').PluginError,
log = require('gulp-util').log,
colors = require('gulp-util').colors
es = require('event-stream'),
Lintspaces = require('lintspaces'),
gutil = require('gulp-util'),
path = require('path'),
appRoot = require('app-root-path'),
colors = require('colors/safe'),
logSymbols = require('log-symbols')
;

@@ -27,4 +29,38 @@

module.exports.reporter = function() {
return es.through(function(file) {
module.exports.reporter = function(options) {
var opts = {
breakOnWarning: false,
prefixLogs: false
};
for (var attr in options) { opts[attr] = options[attr]; }
var totalWarningCount = 0;
var logPrefix = options.prefixLogs ? colors.cyan('[gulp-lintspaces]\t') : '';
function reportFile (filepath, data) {
var lines = [];
var warningLines = Object.keys(data);
var warningCount = Object.keys(data).length;
// Report Filename
lines.push(colors.white.bold.underline(path.relative(appRoot.path, filepath)));
// Loop through and report warnings
warningLines.forEach(function (warningLine) {
var line = colors.grey(' line ' + data[warningLine][0].line) + '\t\t ' + colors.cyan(data[warningLine][0].message);
lines.push(line);
});
lines.push('');
lines.push(' ' + logSymbols.info + ' ' + colors.blue(warningCount + ' whitespace warning' + (warningCount !== 1 ? 's' : '')));
lines = lines.map(function(line) { return logPrefix + line; });
return lines.join('\n') + '\n';
}
// Add report summary
function reportSummary () {
if (totalWarningCount !== 0) {
console.log(logPrefix + logSymbols.info + colors.blue(' ' + totalWarningCount + ' whitespace warning' + (totalWarningCount !== 1 ? 's' : '') + '\n'));
}
}
return es.through(function (file) {
if (file.isNull()) {

@@ -34,23 +70,15 @@ return this.emit('data', file);

// Report file specific stuff only when there are warnings
if (file.lintspaces && Object.keys(file.lintspaces).length) {
for (var line in file.lintspaces) {
file.lintspaces[line].forEach(function(error) {
log(
'gulp-lintspaces',
[
colors.red(error.message),
'in',
file.path + ':' + line
].join(' ')
);
});
}
totalWarningCount += Object.keys(file.lintspaces).length;
console.log(reportFile(file.path, file.lintspaces));
}
if (Object.keys(file.lintspaces).length) {
this.emit('error', new PluginError("gulp-lintspaces", "Found spacing errors"));
return this.emit('data', file);
})
.on('end', function () {
reportSummary();
if (totalWarningCount && options.breakOnWarning) {
this.emit('error', new gutil.PluginError('gulp-lintspaces', 'Linter warnings occurred!'));
}
return this.emit('data', file);
});
}
};
{
"name": "gulp-lintspaces",
"version": "0.3.4",
"version": "0.4.0",
"description": "gulp plugin for lintspaces",

@@ -28,5 +28,9 @@ "main": "index.js",

"dependencies": {
"app-root-path": "^1.0.0",
"colors": "^1.0.3",
"event-stream": "^3.1.1",
"gulp-util": "^2.2.14",
"event-stream": "^3.1.1",
"lintspaces": "^0.3.2"
"lintspaces": "^0.3.2",
"log-symbols": "^1.0.2",
"path": "^0.11.14"
},

@@ -33,0 +37,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc