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

broccoli-lint-eslint

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-lint-eslint - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

CHANGELOG.md

6

Brocfile.js
var eslint = require('./lib/index'),
mergeTrees = require('broccoli-merge-trees');
mergeTrees = require('broccoli-merge-trees');

@@ -10,6 +10,6 @@ // lint plugin code

var test = eslint('test', {
rulePaths: ['conf/rules'],
format: 'eslint/lib/formatters/compact'
rulePaths: ['conf/rules'],
format: 'eslint/lib/formatters/compact'
});
module.exports = mergeTrees([plugin, test], { overwrite: true });

@@ -7,19 +7,19 @@ var Filter = require('broccoli-filter'),

* @param {Array} result Eslint verify result array
* @return {Number} If the returned number is greater than 0 the result contains errors.
* @returns {Number} If the returned number is greater than 0 the result contains errors.
*/
function getResultSeverity (result) {
'use strict';
'use strict';
// count all errors
return result.reduce(function (previous, message) {
if (message.fatal) {
return previous + 1;
}
// count all errors
return result.reduce(function (previous, message) {
if (message.fatal) {
return previous + 1;
}
if (message.severity === 2) {
return previous + 1;
}
if (message.severity === 2) {
return previous + 1;
}
return previous;
}, 0);
return previous;
}, 0);
}

@@ -35,31 +35,31 @@

var EslintValidationFilter = function(inputTree, options, internalOptions) {
'use strict';
var config = {};
'use strict';
var config = {};
if (!(this instanceof EslintValidationFilter)) {
return new EslintValidationFilter(inputTree, options, internalOptions);
}
this.internalOptions = internalOptions || {};
// set inputTree
this.inputTree = inputTree;
if (!(this instanceof EslintValidationFilter)) {
return new EslintValidationFilter(inputTree, options, internalOptions);
}
this.internalOptions = internalOptions || {};
// set inputTree
this.inputTree = inputTree;
options = options || {};
options = options || {};
// set formatter
this.formatter = require(options.format || 'eslint/lib/formatters/stylish');
// set formatter
this.formatter = require(options.format || 'eslint/lib/formatters/stylish');
this.cleanup = function () {};
this.cleanup = function () {};
config.rulePaths = options.rulesdir ? [options.rulesdir] : [];
if ('config' in options) {
config.rulePaths = options.config;
}
config.rulePaths = options.rulesdir ? [options.rulesdir] : [];
if ('config' in options) {
config.rulePaths = options.config;
}
this.cli = new CLIEngine(options);
this.cli = new CLIEngine(options);
this.testGenerator = options.testGenerator;
if (this.testGenerator) {
this.targetExtension = 'eslint-test.js';
}
this.testGenerator = options.testGenerator;
if (this.testGenerator) {
this.targetExtension = 'eslint-test.js';
}
};

@@ -73,33 +73,33 @@

EslintValidationFilter.prototype.processString = function (content, relativePath) {
'use strict';
'use strict';
var messages = [];
var messages = [];
// verify file content
var result = this.cli.executeOnText(content).results[0].messages;
// verify file content
var result = this.cli.executeOnText(content).results[0].messages;
// if verification has result
if (result.length) {
// if verification has result
if (result.length) {
// prepare message format
messages.push({
filePath: relativePath,
messages: result
});
// prepare message format
messages.push({
filePath: relativePath,
messages: result
});
// log formatter output
console.log(this.formatter(messages));
// log formatter output
console.log(this.formatter(messages));
if (getResultSeverity(result) > 0 && 'throwOnError' in this.internalOptions && this.internalOptions.throwOnError === true) {
// throw error if severe messages exist
throw 'severe rule errors';
}
if (getResultSeverity(result) > 0 && 'throwOnError' in this.internalOptions && this.internalOptions.throwOnError === true) {
// throw error if severe messages exist
throw 'severe rule errors';
}
}
if (this.testGenerator) {
return this.testGenerator(relativePath, result);
}
if (this.testGenerator) {
return this.testGenerator(relativePath, result);
}
// return unmodified string
return content;
// return unmodified string
return content;
};
{
"name": "broccoli-lint-eslint",
"version": "0.1.2",
"version": "0.1.3",
"description": "broccoli filter that runs eslint",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -37,8 +37,8 @@ # [broccoli](https://github.com/joliss/broccoli)-lint-eslint

##### rulesdir
##### rulePaths
Type: `String`
Type: `Array`
Default: [built-in rules directory](https://github.com/eslint/eslint/tree/master/lib/rules)
Path to a directory with custom rules. Your custom rules will be used in addition to the built-in ones.
Paths to a directory with custom rules. Your custom rules will be used in addition to the built-in ones.

@@ -45,0 +45,0 @@ Recommended read: [Working with Rules](https://github.com/eslint/eslint/blob/master/docs/developer-guide/working-with-rules.md)

'use strict';
var assert = require('assert'),
fs = require('fs'),
rimraf = require('rimraf');
fs = require('fs'),
rimraf = require('rimraf');
afterEach(function () {
rimraf.sync('temp');
rimraf.sync('broccoli-build.out');
rimraf.sync('temp');
rimraf.sync('broccoli-build.out');
});
it('should reported errors', function () {
var buildLog = fs.readFileSync('broccoli-build.out').toString();
var buildLog = fs.readFileSync('broccoli-build.out').toString();
assert(buildLog.indexOf('Strings must use doublequote.') !== -1, 'Used eslint validation');
assert(buildLog.indexOf('is not in camel case') !== -1, 'Used eslint validation');
assert(buildLog.indexOf('testing custom rules') !== -1, 'Used custom rulesdir rules');
assert(buildLog.indexOf('fixture/1.js') !== -1, 'Shows filepath');
});
assert(buildLog.indexOf('Strings must use doublequote.') !== -1, 'Used eslint validation');
assert(buildLog.indexOf('is not in camel case') !== -1, 'Used eslint validation');
assert(buildLog.indexOf('testing custom rules') !== -1, 'Used custom rulesdir rules');
assert(buildLog.indexOf('fixture/1.js') !== -1, 'Shows filepath');
});

Sorry, the diff of this file is not supported yet

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