Socket
Socket
Sign inDemoInstall

jscs

Package Overview
Dependencies
147
Maintainers
6
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.4 to 3.0.5

21

lib/checker.js

@@ -6,3 +6,2 @@ var vowFs = require('vow-fs');

var utils = require('util');
var path = require('path');

@@ -30,4 +29,2 @@ var NodeConfiguration = require('./config/node-configuration');

StringChecker.prototype.configure.call(this, config);
this._fileExtensions = this._configuration.getFileExtensions();
};

@@ -162,3 +159,3 @@

if (!this._hasCorrectExtension(fullname)) {
if (!this._configuration.hasCorrectExtension(fullname)) {
if (!this._configuration.shouldExtractFile(fullname)) {

@@ -251,18 +248,2 @@ return [];

/**
* Returns true if the file extension matches a file extension to process.
*
* @returns {Boolean}
*/
Checker.prototype._hasCorrectExtension = function(testPath) {
var extension = path.extname(testPath).toLowerCase();
var basename = path.basename(testPath).toLowerCase();
return !(
this._fileExtensions.indexOf(extension) < 0 &&
this._fileExtensions.indexOf(basename) < 0 &&
this._fileExtensions.indexOf('*') < 0
);
};
/**
* Returns new configuration instance.

@@ -269,0 +250,0 @@ *

106

lib/config/configuration.js

@@ -99,2 +99,10 @@ var assert = require('assert');

/**
* List of defined options (not complete).
*
* @protected
* @type {Array}
*/
this._definedOptions = [];
/**
* Default file extensions that would be checked.

@@ -203,5 +211,8 @@ *

// Apply all the options
// Load all the options
this._processConfig(config);
// Load defaults if they weren't set
this._loadDefaults(config);
// Load and apply all the rules

@@ -212,2 +223,17 @@ this._useRules();

/**
* Load default values for options which were not defined
*
* @private
*/
Configuration.prototype._loadDefaults = function() {
if (!this._isDefined('excludeFiles')) {
this._loadExcludedFiles(this._defaultExcludedFileMasks);
}
if (!this._isDefined('fileExtensions')) {
this._loadFileExtensions(this._defaultFileExtensions);
}
};
/**
* Returns resulting configuration after preset is applied and options are processed.

@@ -278,2 +304,3 @@ *

filePath = path.resolve(filePath);
return this._excludedFileMatchers.some(function(matcher) {

@@ -285,2 +312,19 @@ return matcher.match(filePath);

/**
* Returns true if the file extension matches a file extension to process.
*
* @returns {Boolean}
*/
Configuration.prototype.hasCorrectExtension = function(testPath) {
var extension = path.extname(testPath).toLowerCase();
var basename = path.basename(testPath).toLowerCase();
var fileExtensions = this.getFileExtensions();
return !(
fileExtensions.indexOf(extension) < 0 &&
fileExtensions.indexOf(basename) < 0 &&
fileExtensions.indexOf('*') < 0
);
};
/**
* Returns file extension list.

@@ -445,2 +489,6 @@ *

}, this);
if (!this._isDefined('plugins')) {
this._definedOptions.push('plugins');
}
}

@@ -453,2 +501,6 @@

}, this);
if (!this._isDefined('additionalRules')) {
this._definedOptions.push('additionalRules');
}
}

@@ -462,6 +514,2 @@

this._loadFileExtensions(options.fileExtensions);
// Set default extensions if there is no presets that could define their own
} else if (!options.hasOwnProperty('preset')) {
this._loadFileExtensions(this._defaultFileExtensions);
}

@@ -471,6 +519,2 @@

this._loadExcludedFiles(options.excludeFiles);
// Set default masks if there is no presets that could define their own
} else if (!options.hasOwnProperty('preset')) {
this._loadExcludedFiles(this._defaultExcludedFileMasks);
}

@@ -555,2 +599,6 @@

this._errorFilter = errorFilter;
if (!this._isDefined('errorFilter')) {
this._definedOptions.push('errorFilter');
}
};

@@ -570,2 +618,6 @@

this._es3Enabled = Boolean(es3);
if (!this._isDefined('es3')) {
this._definedOptions.push('es3');
}
};

@@ -601,2 +653,6 @@

this._maxErrors = maxErrors;
if (!this._isDefined('fix')) {
this._definedOptions.push('fix');
}
};

@@ -619,2 +675,6 @@

this._fix = fix;
if (!this._isDefined('fix')) {
this._definedOptions.push('fix');
}
};

@@ -647,2 +707,6 @@

if (!this._isDefined('preset')) {
this._definedOptions.push('preset');
}
// Process config from the preset

@@ -663,8 +727,24 @@ this._processConfig(this._presets[preset]);

);
this._fileExtensions = this._fileExtensions.concat(extensions).map(function(ext) {
return ext.toLowerCase();
});
if (!this._isDefined('fileExtensions')) {
this._definedOptions.push('fileExtensions');
}
};
/**
* Is option defined?
*
* @param {String} name - name of the option
*
* @return {Boolean}
*/
Configuration.prototype._isDefined = function(name) {
return this._definedOptions.indexOf(name) > -1;
};
/**
* Load excluded paths.

@@ -684,2 +764,6 @@ *

}, this);
if (!this._isDefined('excludeFiles')) {
this._definedOptions.push('excludeFiles');
}
};

@@ -707,2 +791,6 @@

}, this);
if (!this._isDefined('extract')) {
this._definedOptions.push('extract');
}
};

@@ -709,0 +797,0 @@

@@ -8,3 +8,3 @@ {

"name": "jscs",
"version": "3.0.4",
"version": "3.0.5",
"main": "lib/checker",

@@ -67,3 +67,3 @@ "homepage": "http://jscs.info",

"commander": "~2.9.0",
"cst": "^0.3.0",
"cst": "^0.4.0",
"estraverse": "^4.1.0",

@@ -70,0 +70,0 @@ "exit": "~0.1.2",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc